Copy link to clipboard
Copied
Can anyone please tell me how to edit the XMP Packet, while inside of Illustrator, without using FileInfo? I am writing a Flex PatchPanel Extension, so need access to some DOM parameter like XMPString to change the packet. XMPString does not say it is READ ONLY in the reference manual -- but does not let me change it -- unless I am doing something wrong.
Thanks for any suggestion.
For my setup I have an external program that saves an xmp packet (not rdf) to a file. Using a script in Ilustrator I then read that packet and append it to the active documents existing xmp using XMPFile and XMPUtils. The updated xmp is then saved to the active document using XMPFile and putXmp.
You should be able to skip the external xmp file part and use the setProperty() method directly on a copy of the active documents xmp and then save that back to the .ai file.
Here's a simplified (and worki
...Copy link to clipboard
Copied
Can you write the XMPString to a text file outside of AI, modify it and then replace the existing string? You're right in that it doesn't say it is read only but it sounds like it is from inside AI.
Wait, have you saved an AI file without compression and then looked in the resulting AI file with a text editor. I tried this the other day and seem to remember a whole bunch of xmp statements listed.
Copy link to clipboard
Copied
No. I tried to replace it several ways, but nothing has worked yet.
Copy link to clipboard
Copied
One last try, to find a way to edit xmp packet with a script inside Illstrator... XMPString, is it edit only?
Any other idea?
A simple informed, no way to do it, would be also help at this point.
thanks!
Copy link to clipboard
Copied
At some point I downloaded the XMP SDK, which I haven't really peeked at more - have you looked at that?
Copy link to clipboard
Copied
Yes, that does not help for scripting inside of Illustrator. The problem is the Illustrator team - I am starting to assume - did not implement the Javascript XMP API, like the other CS teams did, to allow for adjusting the XMP packet in their DOM -- just like they don't follow the methods for allowing event management, like the other CS apps did....notice a trend here for the AI team?
Copy link to clipboard
Copied
Unfortunately I don't have any solution for you - but please post any updates if you manage to get any further with this!
Good luck!
Copy link to clipboard
Copied
I've never tried to do it from a string but I've had good success with importing xmp from an external file (my.xmp). Once the external xmp is loaded you can use the XMLUtils to append the external xmp to the xmp in the AI.
Copy link to clipboard
Copied
Thanks for your reply, but I need more help to understand if this is possible...
I have a flex panel that is a palette, that allows the user to enter metadata about the file - just like a custom file info panel - but running as an extension palette, using patch panel - I have to manage the read and write of the xmp packet through AI scripting DOM.
I do not see anything that allows reading and writing the xmppacket -- while inside of Illustrator. XMLutil provides a way to parse the xmp packet, right?
As does the XMP Library for AS, but the issue is how to embed in the packet - while inside of Illustrator. I can do this easily with Photoshop, Indesign, Bridge - (or I could write a C++ extension) -- but I would like to script it.
Can you give more details how you have done this, I assume you mean after the user saves the AI file, you then have to append the xmp to the file, outside of AI? If so, you say xmlutis allows you to append xmp packet to an AI file?
Thanks for your help.
Copy link to clipboard
Copied
For my setup I have an external program that saves an xmp packet (not rdf) to a file. Using a script in Ilustrator I then read that packet and append it to the active documents existing xmp using XMPFile and XMPUtils. The updated xmp is then saved to the active document using XMPFile and putXmp.
You should be able to skip the external xmp file part and use the setProperty() method directly on a copy of the active documents xmp and then save that back to the .ai file.
Here's a simplified (and working) example as it's easier to explain with code:
// Load the XMP Script library
if( xmpLib == undefined ) {
var xmpLib = new ExternalObject("lib:../../Frameworks/AdobeXMPScript");
app.synchronousMode = true;
}
//Create an XMPMeta object from the active documents XMPString:
var docXmp = new XMPMeta(app.activeDocument.XMPString);
//Make a copy that we can work with:
var myXmp = docXmp;
//Make our changes:
myXmp.setProperty(XMPConst.NS_XMP, "CreatorTool", "My Script");
//Append the modified xmp to the original xmp object:
XMPUtils.appendProperties(myXmp, docXmp, XMPConst.APPEND_REPLACE_OLD_VALUES);
//Create a File object of the active document so we can use .fsName (XMPFile seems to be picky):
var myDocFile = new File(app.activeDocument.fullName);
//Open the active document for writing:
var docRef = new XMPFile(myDocFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
//Check that we can write the xmp before writing it
if (docRef.canPutXMP(docXmp)) { docRef.putXMP(docXmp); }
//Save the active document (user will have to re-open file to see updated xmp in file info panel)
docRef.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
Most of what I've learned about the xmp library came from the following pdf so if you haven't already you should check it out:
http://www.adobe.com/devnet/scripting/estk/pdfs/javascript_tools_guide_cs3.pdf
HTH.
Copy link to clipboard
Copied
HTH, Damn, that was the first thing I tried, but for some reason ExternalObject would not load XMPScript library for me, so I thought it did not work.
I will give it a try again, since you obviously got it to work.
Thanks for you time and effort!! T
Copy link to clipboard
Copied
No problem, hope it works out for you. It did take me some fiddling to get the right path to the XMP library for the ExternalObject as the path in the documentation didn't work on my system.
Copy link to clipboard
Copied
I've got this working the same way majorLaser does. What kills me is that the metadata is not shown in the file until the document is closed and reopened... AND if you save the document after you use a script to insert metadata, then the data is removed!!!! Is this a bug or what? Is there any way around it?
Copy link to clipboard
Copied
Hi, i think this is old thread
on hope.. did you found solution for it(metadata is not shown in the file until the document is closed and reopened... AND if you save the document after you use a script to insert metadata, then the data is removed!!!!)?
Copy link to clipboard
Copied
Yes, this is some kind of bug - Illustrator completely mishandles the title field.
Copy link to clipboard
Copied
ok., but how to fix this bug?
i have used following method for store meta data.. but the updated property/data not show in current document.. if i reopen the document then it shown.. if i save/edit the document before reopen then the meta data is removed..
how to fix this issue?
//Open the active document for writing:
var docRef = new XMPFile(myDocFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
//Check that we can write the xmp before writing it
if (docRef.canPutXMP(docXmp)) { docRef.putXMP(docXmp); }
pls help
Thanks
Copy link to clipboard
Copied
I think it's only the title field affected by the Ai re-writing bug, the rest I think should be ok. In any case, save the file first, then save the metadata to it as the 2nd step.
Copy link to clipboard
Copied
...and if you need to reopen it, you can do that too.
Copy link to clipboard
Copied
Yup, juggle that hot potato
Copy link to clipboard
Copied
yes.. finally i have done by reopen the document through code..
Copy link to clipboard
Copied
question about that AdobeXMPScript is that a dll or a jsx?
Copy link to clipboard
Copied
Just playing with this - how can I change the title property? (in the DC namespace)
I can read/write properties in the NS_XMP namespace, but I am having trouble to get something to work in the others... !
Find more inspiration, events, and resources on the new Adobe Community
Explore Now