[]
DsPdfJS API / PdfPage
Represents a page in a PdfDocument.
get annotations():
AnnotationCollection
Gets the list of annotations associated with the PdfPage.
get context():
PdfContext
Gets a PdfContext for the current page.
get cropBox():
Rect|null
Gets or sets a rectangle, in points, defining the visible region of default user space. When the PdfPage is displayed or printed, its contents are to be clipped (cropped) to this rectangle and then imposed on the output medium in some implementation-defined manner. Default value is @mediaBox.
Rect | null
set cropBox(
value):void
Gets or sets a rectangle, in points, defining the visible region of default user space. When the PdfPage is displayed or printed, its contents are to be clipped (cropped) to this rectangle and then imposed on the output medium in some implementation-defined manner. Default value is @mediaBox.
Rect | null
void
get document():
PdfDocument|null
Gets the owner PdfDocument or null, if the PdfPage is orphan.
PdfDocument | null
get height():
number
The height of the PdfPage, in points.
number
get id():
number
Gets the reference to the object.
number
get index():
number
Gets the index of the PdfPage in the owner PdfPageCollection, or -1.
number
get mediaBox():
Rect
Gets or sets the bounds of the PdfPage in points.
set mediaBox(
value):void
Gets or sets the bounds of the PdfPage in points.
void
get om():
ObjectManager
Gets the owner ObjectManager instance.
get rotation():
number
Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed. The value is a multiple of 90.
number
set rotation(
degrees):void
Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed. The value is a multiple of 90.
number
void
get transitionDuration():
number|null
Gets or sets the PdfPage's display duration (also called its advance timing): the maximum length of time, in seconds, that the page shall be displayed during presentations before the viewer application shall automatically advance to the next page. The value of null means that the viewer shall not advance automatically.
number | null
set transitionDuration(
value):void
Gets or sets the PdfPage's display duration (also called its advance timing): the maximum length of time, in seconds, that the page shall be displayed during presentations before the viewer application shall automatically advance to the next page. The value of null means that the viewer shall not advance automatically.
number | null
void
get width():
number
The width of the PdfPage, in points.
number
adjustPoint(
value,fromBottomLeft?,deviceDpiX?,deviceDpiY?):Point
Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and PdfPage#mediaBox (if 'CropBox' is not specified) values. This method should be used when positioning annotations or destinations on a page. Do not use this method when drawing on 'context'.
The Point to adjust.
boolean = false
If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).
number = 72
The horizontal device resolution.
number = 72
The vertical device resolution.
adjustQuadrilateral(
value,fromBottomLeft?,deviceDpiX?,deviceDpiY?):Quadrilateral
Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and PdfPage#mediaBox (if 'CropBox' is not specified) values. This method should be used when positioning annotations or destinations on a page. Do not use this method when drawing on 'context'.
The Quadrilateral to adjust.
boolean = false
If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).
number = 72
The horizontal device resolution.
number = 72
The vertical device resolution.
adjustRect(
value,fromBottomLeft?,deviceDpiX?,deviceDpiY?):Rect
Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and PdfPage#mediaBox (if 'CropBox' is not specified) values. This method should be used when positioning annotations or destinations on a page. Do not use this method when drawing on 'context'.
The Rect to adjust.
boolean = false
If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).
number = 72
The horizontal device resolution.
number = 72
The vertical device resolution.
deleteText(
findTextParams,deleteTextMode):void
Deletes a specified text from the PdfPage.
The text to search for.
The text delete mode.
void
deleteText(
textMapFragment,deleteTextMode):void
Deletes the specified text range from the PdfPage.
The text range.
The text delete mode.
void
draw(
context,x,y,width,height,options?):void
Draws the PdfPage on the given context into the specified rectangle.
The target drawing context.
number
The X coordinate of the destination rectangle.
number
The Y coordinate of the destination rectangle.
number
The width of the destination rectangle.
number
The height of the destination rectangle.
The options for the drawing the PdfPage.
void
const page = doc.pages.getAt(0);
const svgCtx = new SvgContext(300, 500);
page.draw(svgCtx, 0, 0, 300, 500, {
viewStateMode: ViewStateMode.Print
});
const svgDoc = svgCtx.toSvgDocument();
draw(
context,bounds,options?):void
Draws the PdfPage on the given context into the specified rectangle.
The target drawing context.
The destination rectangle.
The options for the drawing the PdfPage.
void
free():
void
Detaches the object from the ObjectManager and deallocates its memory, if possible.
void
getRenderSize(
deviceDpiX?,deviceDpiY?):Size
Gets the size of the PdfPage on a device with specified horizontal and vertical resolutions.
number = 72
The horizontal device resolution.
number = 72
The vertical device resolution.
getText():
string
Retrieves all text on the PdfPage.
string
rebind(
omTo):void
Rebinds the object from the current ObjectManager to the specified one.
The new ObjectManager for the object.
void
replaceText(
findTextParams,newText,font?,fontSize?):void
Replaces a specified text on the PdfPage.
Note that the results may be affected by the current value of the PdfDocument#recognitionAlgorithm property.
The text to search for.
string
The replacement text.
The font to use on 'newText', if null the current font will be used.
Font | null
The font size to use on 'newText', if null the current font size will be used.
number | null
void
replaceText(
textMapFragment,newText,font?,fontSize?):void
Replaces a specified text on the PdfPage.
Note that the results may be affected by the current value of the PdfDocument#recognitionAlgorithm property.
The text range.
string
The replacement text.
The font to use on 'newText', if null the current font will be used.
Font | null
The font size to use on 'newText', if null the current font size will be used.
number | null
void
saveAsPng(
options?):Uint8Array
Saves the PdfPage to a byte array in PNG format.
The options for page export.
Uint8Array
The resulting binary data in PNG format.
const doc = PdfDocument.load(data);
const page = doc.pages.getAt(0);
const imageBytes = page.saveAsPng({ backColor: "GhostWhite" });
saveAsPngImage(
options?):Image
Saves the PdfPage to an Image in PNG format.
The options for page export.
The resulting Image object.
saveAsSvg(
options?):Uint8Array
Saves the PdfPage to a byte array in SVG format.
The options for page export.
Uint8Array
The resulting data in UTF-8 encoded SVG format.
saveAsSvgDocument(
options?):SvgDocument
Saves the PdfPage as an SvgDocument.
The options for page export.
The resulting SvgDocument object.
saveAsSvgGz(
options?):Uint8Array
Saves the PdfPage to a byte array in SVG.GZ format.
The options for page export.
Uint8Array
The resulting binary data in SVG.GZ format.