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

Add PageBox to Document Info Metadata

Community Expert ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

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?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.2K

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

correct answers 1 Correct answer

Community Expert , Nov 28, 2018 Nov 28, 2018

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

Votes

Translate

Translate
Community Expert ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

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

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

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!

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

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.

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

Thanks Test Screen Name – I agree, in this use case it is presumed that the input file is either a single page or all pages are the same size.

It took me a while to work out that one had to add this.pageNum to the code for the current page:

Re: Checking Trim size Quickly

The reason that I wanted to add the trim box info to metadata was for use after imposition, as detailed in the following topic thread:

Re: paste "Trimsize" after impostion

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

Just curious... as this.info.title = "My Text String”; will replace any existing title, is it possible to either add the new text as a prefix or suffix to the existing entry?

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

Sure, like this:

this.info.title = this.info.title + "My Text String";

Or:

this.info.title = "My Text String" + this.info.title;

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

LATEST

Thank you try67, I am not sure how long it would have taken me to figure that one out!

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 ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

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");

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