Class: Page

Core.PDFNet. Page


new Page()

Page is a high-level class representing PDF page object (see 'Page Objects' in Section 3.6.2, 'Page Tree,' in PDF Reference Manual). Among other associated objects, a page object contains: - A series of objects representing the objects drawn on the page (See Element and ElementReader class for examples of how to extract page content). - A list of resources used in drawing the page - Annotations - Beads, private metadata, optional thumbnail image, etc.

Members


<static> Box

Type:
  • number
Properties:
Name Type Description
e_media number
e_crop number
e_bleed number
e_trim number
e_art number
e_user_crop number

<static> EventType

Type:
  • number
Properties:
Name Type Description
e_action_trigger_page_open number
e_action_trigger_page_close number

<static> Rotate

Type:
  • number
Properties:
Name Type Description
e_0 number
e_90 number
e_180 number
e_270 number

Methods


<static> addRotations(r0, r1)

Rotate r0 clockwise by r1
Parameters:
Name Type Description
r0 number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
first rotation.
r1 number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
second rotation.
Returns:
A promise that resolves to returns r0 + r1
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
</pre>

<static> create( [page_dict])

Initialize a page using an existing low-level Cos/SDF page object.
Parameters:
Name Type Argument Description
page_dict Core.PDFNet.Obj <optional>
a low-level (SDF/Cos) page dictionary. Note: This constructor does not copy any data, but is instead the logical equivalent of a type cast. Note: Because PDF::PDFDoc provides a complete high-level interface for Page creation and traversal this constructor is rarely used.
Returns:
A promise that resolves to an object of type: "PDFNet.Page"
Type
Promise.<Core.PDFNet.Page>

<static> degreeToRotation(r)

Convert a number that represents rotation in degrees to a rotation enum.
Parameters:
Name Type Description
r number degree to convert to rotation. Valid numbers are multiples of 90.
Returns:
A promise that resolves to one of four angles; e_0, e_90, e_180 or e_270. Returns e_0 if input is not a multiple 90.
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
</pre>

<static> rotationToDegree(r)

Convert a rotation to a number.
Parameters:
Name Type Description
r number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
rotation to convert to number
Returns:
A promise that resolves to one of four numbers; 0, 90, 180 or 270.
Type
Promise.<number>

<static> subtractRotations(r0, r1)

Rotate r0 counter clockwise by r1.
Parameters:
Name Type Description
r0 number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
first rotation.
r1 number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
second rotation.
Returns:
A promise that resolves to returns r0 r1
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
</pre>

annotInsert(pos, annot)

Adds an annotation at the specified location in a page's annotation array.
Parameters:
Name Type Description
pos number The location in the array to insert the object. The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= GetNumAnnots(), the method appends the annotation to the array.
annot Core.PDFNet.Annot The annotation to add.
Returns:
Type
Promise.<void>

annotPushBack(annot)

Adds an annotation to the end of a page's annotation array.
Parameters:
Name Type Description
annot Core.PDFNet.Annot The annotation to prepend in a page's annotation array.
Returns:
Type
Promise.<void>

annotPushFront(annot)

Adds an annotation to the beginning of a page's annotation array.
Parameters:
Name Type Description
annot Core.PDFNet.Annot The annotation to append in a page's annotation array.
Returns:
Type
Promise.<void>

annotRemove(annot)

Removes the given annotation from the page. Note: Removing the annotation invalidates the given Annot object.
Parameters:
Name Type Description
annot Core.PDFNet.Annot The annotation to remove.
Returns:
Type
Promise.<void>

annotRemoveByIndex(index)

Removes the annotation at a given location. Note: Removing the annotation invalidates any associated Annot object.
Parameters:
Name Type Description
index number A zero based index of the annotation to remove.
Returns:
Type
Promise.<void>

copy()

Copy Constructor
Returns:
A promise that resolves to an object of type: "PDFNet.Page"
Type
Promise.<Core.PDFNet.Page>

findInheritedAttribute(attrib)

Some of the page attributes are designated as inheritable. If such an attribute is omitted from a page object, its value is inherited from an ancestor node in the page tree. If the attribute is a required one, a value must be supplied in an ancestor node; if it is optional and no inherited value is specified, the default value should be used. The function walks up the page inheritance tree in search for specified attribute.
Parameters:
Name Type Description
attrib string A string representing the attribute to search for.
Returns:
A promise that resolves to if the attribute was found return a pointer to the value. Otherwise the function return NULL. Resources dictionary (Required; inheritable) MediaBox rectangle (Required; inheritable) CropBox rectangle (Optional; inheritable) Rotate integer (Optional; inheritable)
Type
Promise.<Core.PDFNet.Obj>

flattenField(field_to_flatten)

Flatten/Merge existing form field appearances with the page content and remove widget annotation. Form 'flattening' refers to the operation that changes active form fields into a static area that is part of the PDF document, just like the other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.
Parameters:
Name Type Description
field_to_flatten Core.PDFNet.Field field to flatten Note: An alternative approach to set the field as read only is using Field.SetFlag(Field::e_read_only, true) method. Unlike Field.SetFlag(...), the result of FlattenField() operation can not be programatically reversed.
Returns:
Type
Promise.<void>

getAnnot(index)

Returns the annotation on the page.
Parameters:
Name Type Description
index number The index of the annotation to get on a page. The first annotation on a page has an index of zero.
Returns:
A promise that resolves to annotation object. If the index is out of range returned Annot object is not valid (i.e. annot.IsValid() returns false).
Type
Promise.<Core.PDFNet.Annot>

getAnnots()

Returns SDF/Cos array containing annotation dictionaries. See Section 8.4 in the PDF Reference for a description of the annotation array.
Returns:
A promise that resolves to an array of annotation dictionaries representing annotations associated with the page or NULL if page dictionary is not specified.
Type
Promise.<Core.PDFNet.Obj>

getBox(type)

Parameters:
Name Type Description
type number
PDFNet.Page.Box = {
	e_media : 0
	e_crop : 1
	e_bleed : 2
	e_trim : 3
	e_art : 4
	e_user_crop : 5
}
The type of the page bounding box. Possible values are: e_media, e_crop, e_bleed, e_trim, and e_art. If the value for 'type' is e_crop, this call is equivalent to GetCropBox(). If the value for 'type' is e_media, this call is equivalent to GetMediaBox().
Returns:
A promise that resolves to the box specified for the page object intersected with the media box.
Type
Promise.<Core.PDFNet.Rect>

getContents()

Returns:
A promise that resolves to nULL if page is empty, otherwise a single stream or an array of streams.
Type
Promise.<Core.PDFNet.Obj>

getCropBox()

Returns:
A promise that resolves to the crop box for this page. The page dimensions are specified in user space coordinates. The crop box is the region of the page to display and print. Note: this method is equivalent to GetBox(Page::e_crop)
Type
Promise.<Core.PDFNet.Rect>

getDefaultMatrix( [flip_y] [, box_type] [, angle])

Parameters:
Name Type Argument Description
flip_y boolean <optional>
this parameter can be used to mirror the page. if 'flip_y' is true the Y axis is not flipped and it is increasing, otherwise Y axis is decreasing.
box_type number <optional>
PDFNet.Page.Box = {
	e_media : 0
	e_crop : 1
	e_bleed : 2
	e_trim : 3
	e_art : 4
	e_user_crop : 5
}
an optional parameter used to specify the page box/region that the matrix should map to. By default, the function transforms user space coordinates to cropped coordinates.
angle number <optional>
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
an optional parameter used to specify page rotation in addition to the rotation specified in the page dictionary. This parameter is usually used to rotate the page without modifying the document itself.
Returns:
A promise that resolves to the matrix that transforms user space coordinates to rotated and cropped coordinates. The origin of this space is the bottom-left of the rotated, cropped page.
Type
Promise.<Core.PDFNet.Matrix2D>

getIndex()

Returns:
A promise that resolves to the Page number indication the position of this Page in document's page sequence. Document's page sequence is indexed from 1. Page number 0 means that the page is not part of document's page sequence or that the page is not valid.
Type
Promise.<number>

getMediaBox()

Returns:
A promise that resolves to the media box for this page. The page dimensions are specified in user space coordinates. The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. Note: this method is equivalent to GetBox(Page::e_media)
Type
Promise.<Core.PDFNet.Rect>

getNumAnnots()

Returns the number of annotations on a page. Widget annotations (form fields) are included in the count.
Returns:
A promise that resolves to the number of annotations on a page.
Type
Promise.<number>

getPageHeight( [box_type])

Parameters:
Name Type Argument Description
box_type number <optional>
PDFNet.Page.Box = {
	e_media : 0
	e_crop : 1
	e_bleed : 2
	e_trim : 3
	e_art : 4
	e_user_crop : 5
}
indicates the page box/region to query for height.
Returns:
A promise that resolves to the height for the given page region/box taking into account page rotation attribute (i.e. /Rotate entry in page dictionary).
Type
Promise.<number>

getPageWidth( [box_type])

Parameters:
Name Type Argument Description
box_type number <optional>
PDFNet.Page.Box = {
	e_media : 0
	e_crop : 1
	e_bleed : 2
	e_trim : 3
	e_art : 4
	e_user_crop : 5
}
indicates the page box/region to query for width.
Returns:
A promise that resolves to the width for the given page region/box taking into account page rotation attribute (i.e. /Rotate entry in page dictionary).
Type
Promise.<number>

getResourceDict()

Returns:
A promise that resolves to a pointer to the page resource dictionary.
Type
Promise.<Core.PDFNet.Obj>

getRotation()

Returns:
A promise that resolves to the rotation value for this page.
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
</pre>

getSDFObj()

Returns the page dictionary.
Returns:
A promise that resolves to the object to the underlying SDF/Cos object.
Type
Promise.<Core.PDFNet.Obj>

getThumb()

Returns:
A promise that resolves to object representing the Image thumbnail.
Type
Promise.<Core.PDFNet.Obj>

getTriggerAction(trigger)

Get the Action associated with the selected Page Trigger event.
Parameters:
Name Type Description
trigger number
PDFNet.Page.EventType = {
	e_action_trigger_page_open : 11
	e_action_trigger_page_close : 12
}
the type of trigger event to get
Returns:
A promise that resolves to the Action Obj if present, otherwise NULL
Type
Promise.<Core.PDFNet.Obj>

getUserUnitSize()

Returns the UserUnit value for the page. A UserUnit is a positive number giving the size of default user space units, in multiples of 1/72 inch.
Returns:
A promise that resolves to the UserUnit value for the page. If the key is not present in the page dictionary the default of 1.0 is returned.
Type
Promise.<number>

getVisibleContentBox()

Returns:
A promise that resolves to the bounding box for this page. The page dimensions are specified in user space coordinates. The bounding box is defined as the smallest rectangle that includes all the visible content on the page.
Type
Promise.<Core.PDFNet.Rect>

hasTransition()

tests whether this page has a transition.
Returns:
A promise that resolves to an object of type: "boolean"
Type
Promise.<boolean>

isValid()

Returns:
A promise that resolves to true if this is a valid (non-null) page, false otherwise. If the function returns false the underlying SDF/Cos object is null or is not valid.
Type
Promise.<boolean>

scale(scale)

A utility method used to scale physical dimensions of the page including all page content.
Parameters:
Name Type Description
scale number A number greater than 0 which is used as a scale factor. For example, calling page.Scale(0.5) will reduce physical dimensions of the page to half its original size, whereas page.Scale(2) will double the physical dimensions of the page and will rescale all page content appropriately. Note: Unlike SetUserUnitSize(unit_size) which is only supported in PDF 1.6 (i.e. Acrobat 7) and above, page.Scale(sc) supports all PDF versions.
Returns:
Type
Promise.<void>

setBox(type, box)

Sets the page bounding box specified by 'page_region' for this page.
Parameters:
Name Type Description
type number
PDFNet.Page.Box = {
	e_media : 0
	e_crop : 1
	e_bleed : 2
	e_trim : 3
	e_art : 4
	e_user_crop : 5
}
The type of the page bounding box. Possible values are: e_media, e_crop, e_bleed, e_trim, and e_art.
box Core.PDFNet.Rect A rectangle specifying the coordinates to set for the box. The coordinates are specified in user space units.
Returns:
Type
Promise.<void>

setCropBox(box)

Sets the crop box for this page. The crop box is the region of the page to display and print.
Parameters:
Name Type Description
box Core.PDFNet.Rect the new crop box for this page. The page dimensions are specified in user space coordinates. The crop box defines the region to which the contents of the page are to be clipped (cropped) when displayed or printed. Note: this method is equivalent to SetBox(Page::e_crop)
Returns:
Type
Promise.<void>

setMediaBox(box)

Sets the media box for this page.
Parameters:
Name Type Description
box Core.PDFNet.Rect the new media box for this page. The page dimensions are specified in user space coordinates. The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. Note: this method is equivalent to SetBox(Page::e_media)
Returns:
Type
Promise.<void>

setRotation(angle)

Sets the rotation value for this page.
Parameters:
Name Type Description
angle number
PDFNet.Page.Rotate = {
	e_0 : 0
	e_90 : 1
	e_180 : 2
	e_270 : 3
}
Rotation value to be set for a given page. Must be one of the Page::Rotate values.
Returns:
Type
Promise.<void>

setUserUnitSize(unit_size)

Sets the UserUnit value for a page.
Parameters:
Name Type Description
unit_size number A positive number giving the size of default user space units, in multiples of 1/72 inch. Note: This is a PDF 1.6 feature. See the implementation note 171 in PDF Reference for details.
Returns:
Type
Promise.<void>