These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Retrieve PDF Page size through JavaScripting

braam
Registered: Jun 2 2008
Posts: 3
Answered

Hi

I must retrieve the pdf page size through Javascripting. Like for instance return the x and y value as an integer.
Ive been succesfull with rotating and deleting pages through javascripting, but this I cant figure out.

Is this possible?

Thank you
Braam Ekermans

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Use the doc method "getPageBox()" method for the "media" box to get the page size in points. 1 point is 1/72 of an inch.

The JavaScript API Reference example:

var aRect = this.getPageBox("Media");
var width = aRect[2] - aRect[0];
var height = aRect[1] - aRect[3];
console.println("Page 1 has a width of " + width + " and a height of " +
height);

// now just add the conversion from points to inches
console.println("Page 1 has a width of " + (width * (1/72) )+ " inches and a height of " +
(height * (1/72) ) + " inches");

George Kaiser

jbfreels
Registered: Feb 19 2008
Posts: 63
Just an FYI, when using getPageBox, you can specify "nPage" as your page number. I imagine you'll be working with multi-page documents. The solution above (copy and pasted from the API reference verbatim (sans points/inches conversion) will only work with page 0 (first page in the document). Also, "Media" isn't a documented working value, unless it's omitted in the documentation.

-jb
braam
Registered: Jun 2 2008
Posts: 3
Thank you for the replies.

It helped alot. :)