Copy link to clipboard
Copied
Hi all,
I'm in the process of batch adding metadata to PDF documents in Adobe DC.
My script is working for all the default elements like Title and Subject, but I'd like to be able to add the key value (name, value) pairs for custom properties as well, but I can't figure out how to access the custom properties to write to them.
Can anyone help me out with this?
Copy link to clipboard
Copied
Take a look at the JavaScript documentation - especially the Doc.info property: Acrobat DC SDK Documentation
In the examples, you will see how the "ISBN" and "PublishDate" custom properties are added. Keep on mind that this will not work in any script running in the free Adobe Reader.
Copy link to clipboard
Copied
The SDK Doc has been helpful, but the properties still aren't getting written to file > properties > custom properties.
Copy link to clipboard
Copied
I would recommend to implement this in steps. The first step should be that you manage to set the custom properties for one document, outside of your loop. Take for example these lines and execute them in the JavaScript console:
this.info.Title = "The Title";
this.info.Subject = "The Subject";
this.info.ModDate = "01/02/2017";
this.info.program = "The Program";
this.info.owner = "The Owner";
If you can get this to work, then you can start to debug things in your loop;
Copy link to clipboard
Copied
Good call!
It's working now.
Thanks!
Copy link to clipboard
Copied
The doc.info object works just like any other JavaScript object; by setting the property, you've created it. For example...
this.info.foo = "bar";
...both creates the metadata field "foo" and sets the value to "bar". Properties can be read in the same way.
Copy link to clipboard
Copied
Would this then appear in the custom properties section in the document?
Because, so far, I've tried it out and it's not worked.
I've got an array of objects that I'm looping through like this:
var i = 0;
obj.forEach(function() {
if (this.documentFileName === obj.filename) {
this.info.Title = obj.title;
this.info.Subject = obj.subject;
this.info.ModDate = obj.datePosted;
this.info.program = obj.program;
this.info.owner = obj.owner;
i++
};
});
And all the default, Title, Subject, ModDate get moved over perfectly, but the program and owner do not. Do I need to set progam and owner somewhere first?
Cheers,
Copy link to clipboard
Copied
Look under the Custom tab of the Document Properties...
Copy link to clipboard
Copied
"with JavaScript"
Copy link to clipboard
Copied
lcreale wrote
"with JavaScript"
I understood that... Run the JS code and then check the Custom tab and you'll see that the information is there.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now