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 s188.8.131.52, s184.108.40.206, Pages
|Name||Type/Allowed Values||Required||Default Value|
|Parent||HexaPDF::Type::PageTreeNode or Hash||true||nil|
|LastModified||HexaPDF::DictionaryFields::PDFDate or String or Time or Date or DateTime||false||nil|
|Resources||HexaPDF::Type::Resources or Hash||false||nil|
|MediaBox||HexaPDF::Rectangle or Array||false||nil|
|CropBox||HexaPDF::Rectangle or Array||false||nil|
|BleedBox||HexaPDF::Rectangle or Array||false||nil|
|TrimBox||HexaPDF::Rectangle or Array||false||nil|
|ArtBox||HexaPDF::Rectangle or Array||false||nil|
|BoxColorInfo||HexaPDF::Dictionary or Hash||false||nil|
|Contents||HexaPDF::Stream or HexaPDF::PDFArray or Hash or Array||false||nil|
|Group||HexaPDF::Dictionary or Hash||false||nil|
|Thumb||HexaPDF::Stream or Hash||false||nil|
|B||HexaPDF::PDFArray or Array||false||nil|
|Trans||HexaPDF::Dictionary or Hash||false||nil|
|Annots||HexaPDF::PDFArray or Array||false||nil|
|AA||HexaPDF::Dictionary or Hash||false||nil|
|Metadata||HexaPDF::Stream or Hash||false||nil|
|PieceInfo||HexaPDF::Dictionary or Hash||false||nil|
|ID||HexaPDF::DictionaryFields::PDFByteString or String||false||nil|
|SeparationInfo||HexaPDF::Dictionary or Hash||false||nil|
|PresSteps||HexaPDF::Dictionary or Hash||false||nil|
|VP||HexaPDF::PDFArray or Array||false||nil|
Public Class Methods
Public Instance Methods
Returns all parent nodes of the page up to the root of the page tree.
The direct parent is the first node in the array and the root node the last.
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
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.
If the media box of the page doesn't have its origin at (0, 0), the canvas origin is translated into the bottom left corner so that this detail doesn't matter when using the canvas. This means that the canvas' origin is always at the bottom left corner of the media box.
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).
Yields each annotation of this page.
Flattens all or the given annotations of the page. Returns an array with all the annotations that couldn't be flattened because they don't have an appearance stream.
Flattening means making the appearances of the annotations part of the content stream of the page and deleting the annotations themselves. Invisible and hidden fields are deleted but not rendered into the content stream.
If an annotation is a form field widget, only the widget will be deleted but not the form field itself.
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. If
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.
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.