Skip to main content
Participant
November 7, 2017
Question

Quick way of showing the trim size in Acrobat Reader and Pro

  • November 7, 2017
  • 5 replies
  • 18931 views

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.

5 replies

Participant
January 28, 2025

Hi there, has anyone tried making this work in the New Acrobat Menu's ? Im using the pro version ... would love this feature to speed up our prepress checking.

jelle wouterv79879982
Participating Frequently
December 5, 2019

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

Thom Parker
Community Expert
Community Expert
December 5, 2019

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.  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
April 26, 2018

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

Stephen Marsh
Community Expert
Community Expert
April 26, 2018

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

Inspiring
October 15, 2018

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

Stephen Marsh
Community Expert
Community Expert
November 10, 2017

Thank you for your generosity in sharing this script code.

Abambo
Community Expert
Community Expert
November 8, 2017

I didn't try this out, as I do not have admin rights on this PC, but it looks promising. I would just change one thing: as the user can set unit preference, you surely have the possibility to query this preference and to use this for showing the trim size. It's definitely a nice one then.

I suppose it works also with crop, art and bleed.

ABAMBO | Hard- and Software Engineer | Photographer
Inspiring
April 26, 2018

You can place the file in the user's JavaScript folder. SinC:\Users\George\AppData\Roaming\Adobe\Acrobat\Privileged\DC\JavaScriptsce this is your user folder, you will have rights to it.

:\Users\[userid]\AppData\Roaming\Adobe\Acrobat\Privileged\DC\JavaScripts

Be sure to replace [userid] with your user ID.

This could be easily modified to show result in inches. One could also move the menu option to the "View" option.

Stephen Marsh
Community Expert
Community Expert
April 27, 2018
This could be easily modified to show result in inches. One could also move the menu option to the "View" option.

Nice suggestion, I agree that the VIEW menu is probably a better place for this than the FILE menu (which is a safe choice as it is not likely to be renamed by Adobe, not that they have renamed or done away with the View menu yet).

Yes, as mentioned in that other post simply changing 0.3528 to 0.0138889 should do the trick. One can also elect to remove rounding, leave it on (13 places or something like that) or round to a smaller set number of decimal places.

Keep in mind that this script is simple in that it only appears to report the values for the first page in the file, it does not dynamically adjust the report based on the current active page or offer a page selection option etc.