Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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: ["", "",]
};
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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))
Copy link to clipboard
Copied
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)
};
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I think you need to create your own custom UI and then link your own created UI to indesign default UI.
Sample