Skip to main content
Stephen Marsh
Community Expert
Community Expert
November 28, 2018
Answered

Add PageBox to Document Info Metadata

  • November 28, 2018
  • 8 replies
  • 1893 views

I would like to add say the Media Box or Trim Box info to the document info metadata, such as title or subject.

It is apparently very easy to add a static string to the document metadata, such as:

this.info.subject = "My Text String"; // adds text string to the document subject metadata

As a newb to scripting, I am having problems adding a variable based off the required page box rather than a hard coded string of static text.

This topic thread is a good example of what I would like to add to the metadata:

Checking Trim size Quickly

function ThePageSize(){

var aRect = this.getPageBox("Trim");

var width = aRect[2] - aRect[0];

var height = aRect[1] - aRect[3];

app.alert("Trim: " + Math.round(width*0.3528) + " mm x "

+ Math.round(height*0.3528) + " mm");

}

Line 5 where it pulls in the bounding size and converts it to metric with some static text is what I would like to add to the metadata.

I’m sure that I am missing something basic and I have not been able to find any examples to adapt. Can anybody please point me in the right direction?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

Simply replace app.alert(...); with this.info.subject = ... ;

8 replies

Stephen Marsh
Community Expert
Community Expert
November 28, 2018

OK, I think I have it now!

var aRect = this.getPageBox("Media");

var width = aRect[2] - aRect[0];

var height = aRect[1] - aRect[3];

this.info.subject = ("Media: " + Math.round(width*0.3528) + " mm x "

+ Math.round(height*0.3528) + " mm");

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 28, 2018

Simply replace app.alert(...); with this.info.subject = ... ;

Stephen Marsh
Community Expert
Community Expert
November 28, 2018

Thank you try67, as I answered this myself while you were replying to my post, after so many false starts it finally became obvious! However I really appreciate your reply, I have marked your answer as correct!

Legend
November 28, 2018

It may be of no importance in this case, but for those reading this in the future, remember that a PDF can have any number of pages, and each page can be different size. This is why it is not document metadata as standard.

Confusingly, Acrobat shows a page size AS IF it is document metadata, in Properties. In fact, it just shows the size of the current page.