Copy link to clipboard
Copied
I entered this as an answer to a question elsewhere but I suppose this is something many would like to know since there's no good built-in way to do it. So here it is again:
What you need to do is to add a simple javascript to Acrobat that creates a new meny option. Here's how:
Open a text editor and paste this into it:
function PageSize(){
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");
}
app.addMenuItem ({cName: "Show trim size", cParent: "File", cExec: "PageSize()" });
Then you save the file as something like trimsize.js on your desktop or elsewhere.
Then open in Windows:
C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\Javascripts\
and copy the file there. You might have to allow it to copy as administrator.
After this you restart Acrobat, and at the bottom of the file menu you will find a new option for showing the trim size.
The path will be a little different if you're using Acrobat Pro or if you're on a Mac but I'm sure you can find it.
Mac path:
/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Resources/JavaScripts/
The nice thing about this script is that it works for Acrobat Reader as well as Pro. In my company the sales people use Reader and don't have access to the trim size at all, so this was very nice for them to have.
Hope you like it and that my little script works for you.
Copy link to clipboard
Copied
A button is a type of form field. You can more easily test your code through a button than through a document level function since it does not require one to restart Acrobat/Reader.
Copy link to clipboard
Copied
I can't see the line
app.addMenuItem ({cName: "Show trim size", cParent: "File", cExec: "PageSize()" });
in your Javascript file.
Copy link to clipboard
Copied
Thank you for your generosity in sharing this script code.
Copy link to clipboard
Copied
Great! Thanks for posting this.
And if we want an accompanying Bleed Size menu option, what needs to be changed in that script?
EDIT: Oh, got it sorted through trial and error. 😉
function BleedSize(){
var aRect = this.getPageBox("Bleed");
var width = aRect[2] - aRect[0];
var height = aRect[1] - aRect[3];
app.alert("Bleed: " + Math.round(width*0.3528) + "x"
+ Math.round(height*0.3528) + " mm");
}
app.addMenuItem ({cName: "Show Bleed Size", cParent: "File", cExec: "BleedSize()" });
Copy link to clipboard
Copied
Also here in more detail:
Re: Checking Trim size Quickly
function ThePageSize(){
var aRect = this.getPageBox("Crop");
var aWidth = aRect[2] - aRect[0];
var aHeight = aRect[1] - aRect[3];
var bRect = this.getPageBox("Art");
var bWidth = bRect[2] - bRect[0];
var bHeight = bRect[1] - bRect[3];
var cRect = this.getPageBox("Trim");
var cWidth = cRect[2] - cRect[0];
var cHeight = cRect[1] - cRect[3];
var dRect = this.getPageBox("Bleed");
var dWidth = dRect[2] - dRect[0];
var dHeight = dRect[1] - dRect[3];
var eRect = this.getPageBox("Media");
var eWidth = eRect[2] - eRect[0];
var eHeight = eRect[1] - eRect[3];
app.alert("Crop: " + Math.round(aWidth*0.3528*100)/100 + " mm x " + Math.round(aHeight*0.3528*100)/100 + " mm" + "\n\n" +
("Art: " + Math.round(bWidth*0.3528*100)/100 + " mm x " + Math.round(bHeight*0.3528*100)/100 + " mm") + "\n\n" +
("Trim: " + Math.round(cWidth*0.3528*100)/100 + " mm x " + Math.round(cHeight*0.3528*100)/100 + " mm") + "\n\n" +
("Bleed: " + Math.round(dWidth*0.3528*100)/100 + " mm x " + Math.round(dHeight*0.3528*100)/100 + " mm") + "\n\n" +
("Media: " + Math.round(eWidth*0.3528*100)/100 + " mm x " + Math.round(eHeight*0.3528*100)/100 + " mm")
);
}
app.addMenuItem ({cName: "Show PageBox Sizes", cParent: "View", cExec: "ThePageSize()" });
Copy link to clipboard
Copied
I would add the "cEnable" parameter to the addButton code so the menu option is only available when a PDF is open.
The addButton line of code would then be:
app.addMenuItem ({cName: "Show PageBox Sizes", cParent: "View", cEnable: "event.rc = (event.target != null);", cExec: "ThePageSize();" });
Copy link to clipboard
Copied
Hi gkaiseril
I can not insert a line of code in scripts ready.
Because after I save - through the text edit - the js file is damaged.
I will thank you if you send me a ready script.
Copy link to clipboard
Copied
Probably because you are not using a text editor.
function ThePageSize(){
var aRect = this.getPageBox("Crop");
var aWidth = aRect[2] - aRect[0];
var aHeight = aRect[1] - aRect[3];
var bRect = this.getPageBox("Art");
var bWidth = bRect[2] - bRect[0];
var bHeight = bRect[1] - bRect[3];
var cRect = this.getPageBox("Trim");
var cWidth = cRect[2] - cRect[0];
var cHeight = cRect[1] - cRect[3];
var dRect = this.getPageBox("Bleed");
var dWidth = dRect[2] - dRect[0];
var dHeight = dRect[1] - dRect[3];
var eRect = this.getPageBox("Media");
var eWidth = eRect[2] - eRect[0];
var eHeight = eRect[1] - eRect[3];
app.alert("Trim box sizes for page " + (this.pageNum + 1) + ":\n\n" +
"Crop: " + Math.round(aWidth*0.3528*100)/100 + " mm x " + Math.round(aHeight*0.3528*100)/100 + " mm \n\n" +
"Art: " + Math.round(bWidth*0.3528*100)/100 + " mm x " + Math.round(bHeight*0.3528*100)/100 + " mm \n\n" +
"Trim: " + Math.round(cWidth*0.3528*100)/100 + " mm x " + Math.round(cHeight*0.3528*100)/100 + " mm \n\n" +
"Bleed: " + Math.round(dWidth*0.3528*100)/100 + " mm x " + Math.round(dHeight*0.3528*100)/100 + " mm \n\n" +
"Media: " + Math.round(eWidth*0.3528*100)/100 + " mm x " + Math.round(eHeight*0.3528*100)/100 + " mm",
3, 0, "Trim Box Sizes"
);
}
app.addMenuItem({cName: "Show PageBox Sizes", cParent: "View", cEnable: "event.rc = event.target != null;", cExec: "ThePageSize();" });
Copy link to clipboard
Copied
Amazing script!!
I would like to know if this it is possible to expand the script to another level.
For example when you have A4 pages on a SRA3 print, you should have 2 trim boxes.
Is it still possible to calculate the size of one of the two trimboxes.
As a Designer I have to tools to calculate it, but the project managers are always asking what the trim size of a pdf is. So if I could use this script for them, it would save me time.
So when you have a 2up of 4up document, you can calculate the size of one of the trimboxes?
btw they are using the acrobat reader
Copy link to clipboard
Copied
The script is straight forward. There is a function for getting the various page boxes and then the results are formated for display.
Each page has a number of page boxes, which are defined in the PDF specification and accessible though the "doc.getPageBox()" function. As far as I know there are no considerations for tiled or imposed pages. Or at least there is nothing available to the scripting model.
You can read about page boxes and PDF coordinates at these links:
https://acrobatusers.com/tutorials/finding-page-boundaries
https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm?sd=40
If the document was tiled or imposed with an application designed to do just this thing (not just printed to a tiled output), then it is possible that this info is hidden in the document. In this case the original program, or a custom plug-in could be used to get the info.
Copy link to clipboard
Copied
Each page in a PDF can only contain one instance of each bounding box. There can't be multiple trim-boxes to a page.