Copy link to clipboard
Copied
Hi All,
Is it possible to modify the meta data in the PDF file acrobat DC using Javascript?
Thanks
 
Copy link to clipboard
Copied
Yes. The metadata property of the Document object gives you direct r/w access to the raw XMP data, as a string.
Copy link to clipboard
Copied
Is it possible to add/modify via Javascript/Applescript?
Copy link to clipboard
Copied
Yes, as I wrote.
Copy link to clipboard
Copied
Could you please share some samples how to modify the XMP data. Im new to this which is really helpful
Copy link to clipboard
Copied
Im trying with below shell script it doesn't change the XMP data
do shell script exiftoolPath & " -Keywords=" & quoted form of newMetadataValue & space & imagePath
Copy link to clipboard
Copied
To do that you can use the info property, like this:
this.info.Keywords = "Text";
Copy link to clipboard
Copied
It's just a string. You can modify it using the various methods available in JS for text manipulation.
Copy link to clipboard
Copied
Im trying to change year 2021 to 2022 but it not works...
this.info.Year = "2022"
 
 
Copy link to clipboard
Copied
Only a few elements are available via Info, these are the PDF metadata which existed before XMP. Author, Keywords, Subject, Title. Changing these fields also automatically updates the XMP. In other cases you have to edit the XML - this is not a simple task.
But the one example you are using is not JavaScript, it is shell script, and is not using Acrobat at all, but an EXIF tool. The JavaScript we are talking about is the internal Acrobat JavaScript, which you cannot run from the command line. Run it from the Acrobat JavaScript console.
Copy link to clipboard
Copied
Thank for the info!
Im tried with the below shell script but it changes the value for CreateDate, CreatorTool and it doesn't the value for year
property exiftoolPath : "/usr/local/bin/exiftool"
set newMetadataValue to "2022"
set imagePath to quoted form of (POSIX path of (choose file of type "pdf"))
-- Add new metadata "Keywords"
do shell script exiftoolPath & " -Year=" & quoted form of newMetadataValue & space & imagePath
 
Copy link to clipboard
Copied
The subject you posted was "Add and modify the XMP data in Acrobat DC using javascript" but this isn't JavaScript and isn't Acrobat DC.
Copy link to clipboard
Copied
FYI I have tried in different soruces also for that only I have shared the shell script here.