PDF Page Coordinates
The starting point for positioning form fields and annotations using JavaScript
PDF page coordinates are measured in points. Since there are 72 points per inch, a regular 8.5" x 11" page is 612 points wide and 792 points high. To create a blank one-page PDF with JavaScript, use the app.newDoc method, which takes two optional input parameters:
nWidth, the page width in points.
nHeight, the page height in points.
If the parameters are omitted, the default values are 612 for nWidth and 792 for nHeight. Therefore, if you run the following script in the JavaScript console of Acrobat Pro it will produce a one-page 8.5" x 11" PDF:
app.newDoc();The following script (with input parameters) will produce the same result:
app.newDoc(612, 792);The following script (with named input parameters) will also produce the same result:
app.newDoc({nWidth: 612, nHeight: 792});So there are three ways to write the script that produce the same result. The first is the easiest.
You can also use math equations in your script to calculate the points like this:
app.newDoc(8.5*72, 11*72);Obviously you wouldn’t need to do calculations for creating this standard one-page PDF, but if you’re creating odd size pages you can save yourself the step of using a calculator to determine the coordinates by adding the calculations into your script and letting the JavaScript engine do them for you. This tip is helpful for positioning form fields and annotation markups that will be outlined in future posts.
Get the course above, and a suite of automation tools for FREE with a Professional subscription.
Keep reading with a 7-day free trial
Subscribe to PDF Automation Station to keep reading this post and get 7 days of free access to the full post archives.



