Is There Any Manifest Permission for activeDocument.filePath in InDesign UXP?

I’m using app.activeDocument.fullName.nativePath to get the file path of the active InDesign document.

I am not using the localFileSystem API (e.g., fs.getFileForOpening() or getFileForSaving()), and I want to avoid requesting localFileSystem permissions in my manifest.json.

new XMPFile(filePathVal, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

Error: XMPFile.constructor - Open, other failure

If I add "localFileSystem": "fullAccess" in my manifest, then XMPFile works.

My Question:
Is there any way to access or write to activeDocument.fullName.nativePath for metadata (like XMPFile) without using localFileSystem permission in the manifest?
Or, is activeDocument implicitly protected by file system security, requiring full permission no matter how I got the file path?

Would you modify a Photoshop PSD document from the outside while it is open in Photoshop and can get rewritten any time? Photoshop may decide to shuffle the XMP info to a completely different location, add arbitrary entries or completely rebuild the file with a different structure.

Same goes for InDesign, and even though the uxp.xmp is living in the same process, it is still outside, a separate library. It has only a very limited understanding how to locate its safe area, and can only do modifications as they fit into reserved space.

If you manage to reach the file against all security measures, you will still find it already opened (by InDesign) thus not writable.

For “any way” of access including changes to your active document, InDesign provides its own XMP subsystem via document.metadataPreferences. Use those.

If you have complicated XMP operations that you want to share with other code (e.g. doing the same to the PSD when PS does not have it open) so you really really insist to stick with uxp.xmp, the InDesign document metadataPreferences can export. As far I understand UXP this should always work given a permitted location such as plugin-temp:. Do your edits on that export and replace or merge the document’s XMP package with the matching metadataPreferences calls.

This is a new (to me) and suboptimal approach so I did not try it myself, please provide feedback how it works.

https://developer.adobe.com/indesign/dom/api/m/MetadataPreference/

See methods save, replace and append.

https://developer.adobe.com/indesign/uxp/reference/uxp-api/reference-js/Modules/fs/

See UXP docs for plugin-temp and alike.

I hope the pasted links make it thru this forum software, displaying errors here.

1 Like

hello sir I have use metaPreferences
but this not work
const getXmpData = () => {

var doc = app.activeDocument;

var xmpStr = doc.metadataPreferences.metadata;

if (!xmpStr || xmpStr.length === 0) {

  console.log("No metadata found.");

  return;

}

var xmp = new XMPMeta(xmpStr);

var customNS = "http://your.custom.namespace/";

var prefix = "fileInfo";

XMPMeta.registerNamespace(customNS, prefix);

var prop = xmp.getProperty(customNS, "rawData");

if (prop) {

  console.log("Custom metadata:\\n" + prop.value);

} else {

  console.log("Custom metadata not found.");

}

};
I have question metaPreferences only work extendscript not uxp?
I have direct access without external link xmlFile activeDocument rawData ? get and add,update and delete?