XMPMetaObj.setStructField and appendArrayItem not working in InDesign UXP?
Hii all,
I’m trying to add structured and array metadata in InDesign UXP using the new XMPMeta class, but I’m running into issues.
I have also registered the namespace, but setStructField() and appendArrayItem() do not work.
const doc = app.activeDocument;
const namespaceUri = "http://test.com/ns/";
const xmp = new XMPMeta(doc.metadataPreferences.rawXMP || "");
xmp.setStructField(
namespaceUri,
"testKey",
namespaceUri,
"testName",
"testValue"
);
Example to append an array item
xmp.appendArrayItem(
namespaceUri,
"TestArray",
"ArrayItemValue"
);
doc.metadataPreferences.rawXMP = xmp.serialize();
According to the documentation:
XMPMetaObj.setStructField(schemaNS, structName, fieldNS, fieldName, fieldValue[, options])
XMPMetaObj.appendArrayItem(schemaNS, arrayName, itemValue[, itemOptions, arrayOptions])
But the metadata does not appear in Raw Data or the metadata panel.
My questions:
1. setStructField() or appendArrayItem() not fully supported in InDesign UXP yet?
2. Is there a known bug or limitation with writing structured/array metadata this way?
3. What is the recommended or working way to add custom structured XMP metadata in UXP?
4. I hope I explained it clearly. Is there any solution to make this work in UXP?
Thanks!
