reading XMP data in scripts broken by 25.4 update.
Illustrator 25.4 update broke scripts that try to read XMP data that worked in previous versions of Illustrator. This is the Mac version (have not tried in Windows).
It appears to be getting the error on this line:
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
Comparing the frameworks in the package contents for 25.3.1 vs 25.4, the AdobeXMPScript framework appears to be missing in 25.4.
Below is an example script to read font data that worked in 25.3, but errors loading the library in 25.4
// load XMP Library
function loadXMPLibrary() {
if (!ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
} catch (e) {
alert('Unable to load the AdobeXMPScript library!');
return false;
}
}
return true;
}
// unload XMP Library
function unloadXMPLibrary() {
if (ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
} catch (e) {
alert('Unable to unload the AdobeXMPScript library!');
}
}
}
// list used fonts
function list_fonts () {
var doc = app.activeDocument;
var fontsInfo = [];
loadXMPLibrary ();
fontsInfo.push (getFontsInfo (doc.fullName));
unloadXMPLibrary ();
var info = fontsInfo.join ('\n\n');
return info;
}
// search used fonts
function getFontsInfo(file) {
var arr = [],
xmpFile,
oXmp,
fontNumber,
i,
path,
fontfamily,
fontface,
ns = 'http://ns.adobe.com/xap/1.0/t/pg/';
xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPENFORREAD);
oXmp = xmpFile.getXMP();
fontNumber = oXmp.countArrayItems(ns, 'xmpTPg:Fonts');
xmpFile.closeFile(XMPConst.CLOSEUPDATESAFELY);
if (fontNumber) {
for (i = 1; i <= fontNumber; i++) {
path = XMPUtils.composeArrayItemPath(ns, 'xmpTPg:Fonts', i);
fontfamily = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontFamily');
fontface = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontFace');
arr.push([fontfamily+' '+fontface]);
}
}
return arr.join(', ');
}
alert ("Fonts used in this document: \n" + list_fonts ());
We have the fix available in the latest prerelease build 26.0
Please update Illustrator using Adobe Creative Cloud application to the latest prerelease build from prerelease section
Warm Regards,
Aishwarya G Gadodia
-
Kris Landes commented
This issue is impacting our studio as well. We've downgraded back to a stable version of Illustrator for the time being, but would love to see a fix implemented for this soon.
-
James Lockman commented
I imported AdobeXMPScript framework from Illustrator 24.3.1 (yes, 24 not 25!) and things were working fine for me.
-
Kevin Bhunut commented
This is currently breaking Custom Metadata Panel extension.
var xmpLib = new ExternalObject("lib:AdobeXMPScript");
File or folder does not exist -
David Hamer commented
This one is breaking our pipeline, exporting from Illustrator to Spine. Really hoping for a quick fix!
-
Kevin A. commented
Glad to hear this is being looked at! We also stumbled into this issue on 25.4.1. We use the XMP library to embed some extra data in PDFs so it's a critical component for us.
I was able to work around it by importing the AdobeXMPScript framework from Illustrator 25.3.1. Not sure how safe this is so YMMV, but figured I'd document it anyway:
MacOS:
- Uninstall Illustrator 2021
- From the CC App's "Other Versions" list, install Illustrator 25.3.1
- Open Applications/Adobe Illustrator 2021
- Right-click on "Adobe Illustrator 2021.app" and choose "Show Package Contents"
- Browse down to Contents/Frameworks
- Copy the "AdobeXMPScript.framework" folder to your desktop
- Update Illustrator back to 25.4.1
- Open "Applications/Adobe Illustrator 2021" again
- Right-Click on "Adobe Illustrator 2021.app" and choose "Show package contents" again
- Browse down to Contents/Frameworks
- Paste the "AdobeXMPScript.framework" folder from your desktop into this Contents/Frameworks folder
- Restart Illustrator and try your scriptIn my testing this is not an issue on the Windows build. Mac Only (as seems to be happening more frequently these days...)
-
Jason commented
Illustrator 25.4 update broke scripts that try to read XMP data that worked in previous versions of Illustrator.
It appears to be getting the error on this line:
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
Below is an example script to read font data that worked in 25.3, but errors loading the library in 25.4
// load XMP Library
function loadXMPLibrary() {
if (!ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
} catch (e) {
alert('Unable to load the AdobeXMPScript library!');
return false;
}
}
return true;
}
// unload XMP Library
function unloadXMPLibrary() {
if (ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
} catch (e) {
alert('Unable to unload the AdobeXMPScript library!');
}
}
}
// list used fonts
function list_fonts () {
var doc = app.activeDocument;
var fontsInfo = [];
loadXMPLibrary ();
fontsInfo.push (getFontsInfo (doc.fullName));
unloadXMPLibrary ();
var info = fontsInfo.join ('\n\n');
return info;
}
// search used fonts
function getFontsInfo(file) {
var arr = [],
xmpFile,
oXmp,
fontNumber,
i,
path,
fontfamily,
fontface,
ns = 'http://ns.adobe.com/xap/1.0/t/pg/';
xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
oXmp = xmpFile.getXMP();
fontNumber = oXmp.countArrayItems(ns, 'xmpTPg:Fonts');
xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
if (fontNumber) {
for (i = 1; i <= fontNumber; i++) {
path = XMPUtils.composeArrayItemPath(ns, 'xmpTPg:Fonts', i);
fontfamily = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontFamily');
fontface = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontFace');
arr.push([fontfamily+' '+fontface]);
}
}return arr.join(', ');
}
alert ("Fonts used in this document: \n" + list_fonts ());