Creating and Modifying PDF Documents
Creating and Modifying PDF Files
4
For example, the following code crops pages 2-5 of the document to a 400 by 500 pixel
area:
this.setPageBoxes({
cBox: "Crop",
nStart: 2,
nEnd: 5,
rBox: [100,100,500,600]
});
The
getPageBox
method accepts the following parameters:
●
●
cBox
: the type of box
nPage
: the zero-based index of the page
For example, the following code retrieves the crop box for page 3:
var rect = this.getPageBox("Crop", 3);
Rotating Pages
You may use Acrobat JavaScript to rotate pages in 90-degree increments in the clockwise
direction relative to the normal position. This means that if you specify a 90-degree
rotation, no matter what the current orientation is, the upper portion of the page is placed
on the right side of your screen.
The
doc
object’s
setPageRotations
and
getPageRotation
methods are used to
set and retrieve page rotations.
The
setPageRotations
method accepts three parameters:
●
●
●
nStart
: the zero-based index of the beginning page
nEnd
: the zero-based index of the last page
nRotate
: 0, 90, 180, or 270 are the possible values for the clockwise rotation
In the following example, pages 2 and 5 are rotated 90 degrees in the clockwise direction:
this.setPageRotations(2,5,90);
To retrieve the rotation for a given page, invoke the
doc
object’s
getPageRotation
method, which requires only the page number as a parameter. The following code retrieves
and displays the rotation in degrees for page 3 of the document:
var rotation = this.getPageRotation(3);
console.println("Page 3 is rotated " + rotation + " degrees.");
Acrobat JavaScript Scripting Guide
71