Class PDFNet.Page
PDFNet.Page
Constructor Attributes | Constructor Name and Description |
---|---|
PDFNet.Page(id)
Page is a high-level class representing PDF page object (see 'Page Objects' in
Section 3.6.2, 'Page Tree,' in PDF Reference Manual).
|
Method Attributes | Method Name and Description |
---|---|
<static> |
PDFNet.Page.addRotations(r0, r1)
Rotate r0 clockwise by r1
|
annotInsert(pos, annot)
Adds an annotation at the specified location in a page's annotation array.
|
|
annotPushBack(annot)
Adds an annotation to the end of a page's annotation array.
|
|
annotPushFront(annot)
Adds an annotation to the beginning of a page's annotation array.
|
|
annotRemove(annot)
Removes the given annotation from the page.
|
|
annotRemoveByIndex(index)
Removes the annotation at a given location.
|
|
copy()
Copy Constructor
|
|
<static> |
PDFNet.Page.create(page_dict)
Initialize a page using an existing low-level Cos/SDF page object.
|
<static> |
PDFNet.Page.degreeToRotation(r)
Convert a number that represents rotation in degrees to a rotation enum.
|
findInheritedAttribute(attrib)
Some of the page attributes are designated as inheritable.
|
|
flattenField(field_to_flatten)
Flatten/Merge existing form field appearances with the page content and
remove widget annotation.
|
|
getAnnot(index)
Returns the annotation on the page.
|
|
Returns SDF/Cos array containing annotation dictionaries.
|
|
getBox(type)
|
|
getDefaultMatrix(flip_y, box_type, angle)
|
|
getIndex()
|
|
Returns the number of annotations on a page.
|
|
getPageHeight(box_type)
|
|
getPageWidth(box_type)
|
|
Returns the page dictionary.
|
|
getThumb()
|
|
getTriggerAction(trigger)
[Documentation Not Yet Added]
|
|
Returns the UserUnit value for the page.
|
|
tests whether this page has a transition.
|
|
isValid()
|
|
<static> |
PDFNet.Page.rotationToDegree(r)
Convert a rotation to a number.
|
scale(scale)
A utility method used to scale physical dimensions of the page including
all page content.
|
|
setBox(type, box)
Sets the page bounding box specified by 'page_region' for this page.
|
|
setCropBox(box)
Sets the crop box for this page.
|
|
setMediaBox(box)
Sets the media box for this page.
|
|
setRotation(angle)
Sets the rotation value for this page.
|
|
setUserUnitSize(unit_size)
Sets the UserUnit value for a page.
|
|
<static> |
PDFNet.Page.subtractRotations(r0, r1)
Rotate r0 counter clockwise by r1.
|
Class Detail
PDFNet.Page(id)
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.
- Parameters:
- id
Method Detail
<static>
{number}
PDFNet.Page.addRotations(r0, r1)
Rotate r0 clockwise by r1
Return value enum:PDFNet.Page.Rotate = { e_0 : 0 e_90 : 1 e_180 : 2 e_270 : 3 }
- Parameters:
- {number} r0
- first rotation.
- {number} r1
- second rotation.
- Returns:
- {number} A promise that resolves to returns r0 + r1
annotInsert(pos, annot)
Adds an annotation at the specified location in a page's annotation array.
- Parameters:
- {number} pos
- 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} annot
- The annotation to add.
annotPushBack(annot)
Adds an annotation to the end of a page's annotation array.
- Parameters:
- {Annot} annot
- The annotation to prepend in a page's annotation array.
annotPushFront(annot)
Adds an annotation to the beginning of a page's annotation array.
- Parameters:
- {Annot} annot
- The annotation to append in a page's annotation array.
annotRemove(annot)
Removes the given annotation from the page.
- Parameters:
- {Annot} annot
- The annotation to remove.
annotRemoveByIndex(index)
Removes the annotation at a given location.
- Parameters:
- {number} index
- A zero based index of the annotation to remove.
{Page}
copy()
Copy Constructor
- Returns:
- {Page} A promise that resolves to an object of type: "Page" (generated documentation)
<static>
{Page}
PDFNet.Page.create(page_dict)
Initialize a page using an existing low-level Cos/SDF page object.
- Parameters:
- {Obj} page_dict
- a low-level (SDF/Cos) page dictionary.
- Returns:
- {Page} A promise that resolves to an object of type: "Page" (generated documentation)
<static>
{number}
PDFNet.Page.degreeToRotation(r)
Convert a number that represents rotation in degrees to a rotation enum.
Return value enum:PDFNet.Page.Rotate = { e_0 : 0 e_90 : 1 e_180 : 2 e_270 : 3 }
- Parameters:
- {number} r
- degree to convert to rotation. Valid numbers are multiples of 90.
- Returns:
- {number} 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.
{Obj}
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:
- {string} attrib
- A string representing the attribute to search for.
- Returns:
- {Obj} 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)
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:
- {field} field_to_flatten
- field to flatten
{Annot}
getAnnot(index)
Returns the annotation on the page.
- Parameters:
- {number} index
- The index of the annotation to get on a page. The first annotation on a page has an index of zero.
- Returns:
- {Annot} 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).
{Obj}
getAnnots()
Returns SDF/Cos array containing annotation dictionaries. See Section 8.4 in
the PDF Reference for a description of the annotation array.
- Returns:
- {Obj} A promise that resolves to an array of annotation dictionaries representing annotations associated with the page or NULL if page dictionary is not specified.
{rect}
getBox(type)
- Parameters:
- {number} type
- 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:
- {rect} A promise that resolves to the box specified for the page object intersected with the media box.
{Obj}
getContents()
- Returns:
- {Obj} A promise that resolves to nULL if page is empty, otherwise a single stream or an array of streams.
{rect}
getCropBox()
- Returns:
- {rect} 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.
{matrix2d}
getDefaultMatrix(flip_y, box_type, angle)
- Parameters:
- {boolean} flip_y
- 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.
- {number} box_type
- 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.
- {number} angle
- 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:
- {matrix2d} 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.
{number}
getIndex()
- Returns:
- {number} 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.
{rect}
getMediaBox()
- Returns:
- {rect} 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.
{number}
getNumAnnots()
Returns the number of annotations on a page. Widget annotations (form fields) are
included in the count.
- Returns:
- {number} A promise that resolves to the number of annotations on a page.
{number}
getPageHeight(box_type)
- Parameters:
- {number} box_type
- indicates the page box/region to query for height.
- Returns:
- {number} 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).
{number}
getPageWidth(box_type)
- Parameters:
- {number} box_type
- indicates the page box/region to query for width.
- Returns:
- {number} 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).
{Obj}
getResourceDict()
- Returns:
- {Obj} A promise that resolves to a pointer to the page resource dictionary.
{number}
getRotation()
Return value enum:PDFNet.Page.Rotate = { e_0 : 0 e_90 : 1 e_180 : 2 e_270 : 3 }
- Returns:
- {number} A promise that resolves to the rotation value for this page.
{Obj}
getSDFObj()
Returns the page dictionary.
- Returns:
- {Obj} A promise that resolves to the object to the underlying SDF/Cos object.
{Obj}
getThumb()
- Returns:
- {Obj} A promise that resolves to object representing the Image thumbnail.
{Obj}
getTriggerAction(trigger)
[Documentation Not Yet Added]
- Parameters:
- {number/enum} trigger
- (generated enum documentation)
PDFNet.Page.EventType = { e_action_trigger_page_open : 11 e_action_trigger_page_close : 12 }
- Returns:
- {Obj} A promise that resolves to an object of type: "Obj" (generated documentation)
{number}
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:
- {number} 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.
{rect}
getVisibleContentBox()
- Returns:
- {rect} 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.
{[ERROR]}
hasTransition()
tests whether this page has a transition.
- Returns:
- {[ERROR]} A promise that resolves to an unknown type (generated documentation)
{boolean}
isValid()
- Returns:
- {boolean} 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.
<static>
{number}
PDFNet.Page.rotationToDegree(r)
Convert a rotation to a number.
- Parameters:
- {number} r
- rotation to convert to number
- Returns:
- {number} A promise that resolves to one of four numbers; 0, 90, 180 or 270.
scale(scale)
A utility method used to scale physical dimensions of the page including
all page content.
- Parameters:
- {number} scale
- 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.
setBox(type, box)
Sets the page bounding box specified by 'page_region' for this page.
- Parameters:
- {number} type
- The type of the page bounding box. Possible values are: e_media, e_crop, e_bleed, e_trim, and e_art.
- {rect} box
- A rectangle specifying the coordinates to set for the box. The coordinates are specified in user space units.
setCropBox(box)
Sets the crop box for this page. The crop box is the region of the page to
display and print.
- Parameters:
- {rect} box
- 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.
setMediaBox(box)
Sets the media box for this page.
- Parameters:
- {rect} box
- 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.
setRotation(angle)
Sets the rotation value for this page.
- Parameters:
- {number} angle
- Rotation value to be set for a given page. Must be one of the Page::Rotate values.
setUserUnitSize(unit_size)
Sets the UserUnit value for a page.
- Parameters:
- {number} unit_size
- A positive number giving the size of default user space units, in multiples of 1/72 inch.
<static>
{number}
PDFNet.Page.subtractRotations(r0, r1)
Rotate r0 counter clockwise by r1.
Return value enum:PDFNet.Page.Rotate = { e_0 : 0 e_90 : 1 e_180 : 2 e_270 : 3 }
- Parameters:
- {number} r0
- first rotation.
- {number} r1
- second rotation.
- Returns:
- {number} A promise that resolves to returns r0 r1