• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add and modify the XMP data in Acrobat DC using javascript

Contributor ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

Hi All,

Is it possible to modify the meta data in the PDF file acrobat DC using Javascript?

 

Screenshot 2022-04-07 at 11.53.27 PM.png

 

Thanks

 

 

TOPICS
JavaScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2022 Apr 07, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

Is it possible to add/modify via Javascript/Applescript?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

Yes, as I wrote.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

To do that you can use the info property, like this:

 

this.info.Keywords = "Text";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

It's just a string. You can modify it using the various methods available in JS for text manipulation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

Im trying to change year 2021 to 2022 but it not works...

this.info.Year = "2022"

Screenshot 2022-04-08 at 2.11.05 PM.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2022 Apr 08, 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

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



Screenshot 2022-04-08 at 2.11.05 PM.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2022 Apr 08, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

LATEST

FYI I have tried in different soruces also for that only I have shared the shell script here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines