Skip to main content
Known Participant
December 7, 2021
Question

new XMP meta Data Field in InDesign through Javascript

  • December 7, 2021
  • 3 replies
  • 1370 views

Hi,

I would like to add a new XMP metadata field in indesign (see below snapshot).

).

 

Can you please guide me how to create this field via JavaScript.

 

This topic has been closed for replies.

3 replies

rob day
Community Expert
June 8, 2022

Hi @Asuvath , You can customize the Raw Data to include property value pairs:

 

 

var md = app.activeDocument.metadataPreferences;
var ns = "http://ns.adobe.com/xap/1.0/";
md.setProperty(ns, "Name", "John Doe")

 

 

 

 

 

Here’s an example that loops thru an object:

 

 

var md = app.activeDocument.metadataPreferences;
var ns = "http://ns.adobe.com/xap/1.0/";
var p, v;

//a json object
var o = {"Name":"John Doe","id":"1234","Address":"Main Street"}
var props = o.reflect.properties;

for (var i = 0; i < props.length-4; i++){
    p = props[i].name
    v = o[props[i]]
    md.setProperty(ns, p, v)
};   

 

AsuvathAuthor
Known Participant
June 9, 2022

Hi @rob day ,
Thanks for the response. Is there any way to create the new label under "Raw Data" with some text field as shown in my screenshot?


So the user may know visibly even if there are do not know about the XMP coding.

Thanks

rob day
Community Expert
June 9, 2022

I don‘t think there is a way to alter the File Info UI via Javascript. You must be running a third party extension to get the Relay item?

SumitKumar
Inspiring
December 31, 2021

Hi @Asuvath ,

 

Here is the sample code, you need to update values.

var myDoc = app.documents[0];
myDoc.metadataPreferences.properties = {
    author: "",
    copyrightInfoURL: "",
    copyrightNotice: "",
    copyrightStatus: "",
    description: "",
    documentTitle: "",
    jobName: "",
    keywords: ["", "",]

};

 

-Sumit
AsuvathAuthor
Known Participant
June 8, 2022

Hi Sumit,

Thanks for the response. Sorry for the late replies. Actually my request is to create the new field under meta data. 
Your code will be update the information in default meta data fields (Autor, title, etc.).
Is there any possible way to create the new meta data field?

Thanks
Asuvath

rob day
Community Expert
June 9, 2022

Not sure if this helps, but you can also get metadata, so you could display a Raw property in a dialog like this:

 

var md = app.activeDocument.metadataPreferences;
var ns = "http://ns.adobe.com/xap/1.0/"
var p = "Name"
alert("This Document’s " + p +" property is set to: " + md.getProperty(ns, p))

 

Mike Witherell
Community Expert
December 31, 2021