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:
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?
Simply replace app.alert(...); with this.info.subject = ... ;
Copy link to clipboard
Copied
Simply replace app.alert(...); with this.info.subject = ... ;
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!
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.
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:
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?
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;
Copy link to clipboard
Copied
Thank you try67, I am not sure how long it would have taken me to figure that one out!
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");