Represents a page of a PDF document.
A page object contains the meta information for a page. Most of the fields are independent from the page's content like the /Dur field. However, some of them (like /Resources or /UserUnit) influence how or if the page's content can be rendered correctly.
A number of field values can also be inherited: /Resources, /MediaBox, /CropBox, /Rotate. Field inheritance means that if a field is not set on the page object itself, the value is taken from the nearest page tree ancestor that has this value set.
See: PDF1.7 s22.214.171.124, s126.96.36.199, Pages
Public Class Methods
Public Instance Methods
rectangle is given, returns the rectangle defining a
certain kind of box for the page. Otherwise sets the value for the given
box type to
rectangle (an array with four values or a HexaPDF::Rectangle).
This method should be used instead of directly accessing any of /MediaBox, /CropBox, /BleedBox, /ArtBox or /TrimBox because it also takes the fallback values into account!
The following types are allowed:
The media box defines the boundaries of the medium the page is to be printed on.
The crop box defines the region to which the contents of the page should be clipped when it is displayed or printed. The default is the media box.
The bleed box defines the region to which the contents of the page should be clipped when output in a production environment. The default is the crop box.
The trim box defines the intended dimensions of the page after trimming. The default value is the crop box.
The art box defines the region of the page's meaningful content as intended by the author. The default is the crop box.
See: PDF1.7 s14.11.2
Returns the requested type of canvas for the page.
The canvas object is cached once it is created so that its graphics state is correctly retained without the need for parsing its contents.
Can either be
:page for getting the canvas for the page itself (only valid for initially empty pages)
:overlay for getting the canvas for drawing over the page contents
:underlay for getting the canvas for drawing unter the page contents
Returns the concatenated stream data from the content streams as binary string.
Note: Any modifications done to the returned value *won't* be reflected in any of the streams' data!
Replaces the contents of the page with the given string.
This is done by deleting all but the first content stream and reusing this content stream; or by creating a new one if no content stream exists.
Copies the page's inherited values from the ancestor page tree nodes into a hash and returns the hash.
The hash can then be used to update the page itself (e.g. when moving a page from one position to another) or another page (e.g. when importing a page from another document).
Returns the index of the page in the page tree.
true since page objects must always be indirect.
Returns the orientation of the media box, either :portrait or :landscape.
Processes the content streams associated with the page with the given processor object.
Returns the possibly inherited resource dictionary which is automatically created if it doesn't exist.
Rotates the page
angle degrees counterclockwise where
angle has to be a multiple of 90.
Positive values rotate the page to the left, negative values to the right.
true, the rotation is not done via
the page's meta data but by “rotating” the canvas itself.
Note that the :Rotate key of a page object describes the angle in a clockwise orientation but this method uses counterclockwise rotation to be consistent with other rotation methods (e.g. Canvas#rotate).
Creates a Form XObject from the page's dictionary and contents for the given PDF document.
reference is true, the page's contents is referenced
when possible to avoid unnecessary decoding/encoding.
Note 1: The created Form XObject is not added to the document automatically!
Note 2: If
reference is false and if a canvas is used on this
page (see canvas), this method
should only be called once the contents of the page has been fully defined.
The reason is that during the copying of the content stream data the
contents may be modified to make it a fully valid content stream.