Skip to main content
lcreale
Participant
August 1, 2017
Question

How do I add custom properties with JavaScript in Adobe DC?

  • August 1, 2017
  • 2 replies
  • 4807 views

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?

This topic has been closed for replies.

2 replies

Joel Geraci
Community Expert
Community Expert
August 1, 2017

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.

lcreale
lcrealeAuthor
Participant
August 1, 2017

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,

try67
Community Expert
Community Expert
August 1, 2017

Look under the Custom tab of the Document Properties...

Karl Heinz  Kremer
Community Expert
Community Expert
August 1, 2017

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.

lcreale
lcrealeAuthor
Participant
August 1, 2017

The SDK Doc has been helpful, but the properties still aren't getting written to file > properties > custom properties.

Karl Heinz  Kremer
Community Expert
Community Expert
August 1, 2017

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;