FoxitPDFSDKforWeb  7.1.1
Foxit PDF SDK for Web
PDFPage Class Reference

Public Member Functions

 addAnnot (annotJson)
 Add an annotation into the current page. This method may add an annotation along with an associated annotation like popup. More...
 
 addAnnotGroup (annotJsons, headerIndex)
 Add a group annotation into the current page. This method may add an annotation along with an associated annotation like popup. More...
 
 addImage (imageBuffer, rect)
 Add the image to page. More...
 
 addWatermark (data)
 Add a page watermark. More...
 
 flatten (option)
 Flatten all annotations and interactive form fields in a Page. More...
 
 getAnnotCount ()
 Gets the total amount of all annotations in a specified page. More...
 
 getAnnotIdAtDevicePoint (point, tolerance, matrix)
 Get the specified position of an annotation in device page coordinate. More...
 
 getAnnots ()
 Get an array of all annotations in a page. More...
 
 getAnnotsByIdArray (ids)
 Get an array of page annotation ID which can be obtained by Annot::getUniqueID(). More...
 
 getAnnotTree ()
 Get a structrual tree of all annotations in a specified page. More...
 
 getCharInfoAtPoint (point, tolerance=0)
 Get character information at a specified position, in PDF coordination system. More...
 
 getDeviceMatrix ()
 Get the device matrix for the page. More...
 
 getDevicePoint (point, scale=1)
 Convert PDF coordinates to device coordinates for the page. More...
 
 getDeviceRect (pdfRect, scale=1, rotate=0)
 Convert PDFRect to deviceRect. More...
 
 getHeight ()
 Get page height. More...
 
 getIndex ()
 Get page's index. More...
 
 getMarkupAnnots ()
 Get only markup annotations in the current page. More...
 
 getPDFDoc ()
 Get the document object. More...
 
 getPDFMatrix ()
 Get page matrix. More...
 
 getRotation ()
 Get page rotation angle. More...
 
 getRotationAngle ()
 Get page rotation angle. More...
 
 getTextRectsAtRect (rect)
 Get page text rectangles in specified rectangle. More...
 
 getTextSearch (pattern, flags)
 Get PageTextSearch with specified pattern and flags. More...
 
 getThumb ()
 Get the PDF stream of "Thumb". More...
 
 getWidth ()
 Get page width. More...
 
 markRedactAnnot (rects, annot)
 Mark page contents (text object, image object, and path object) which are to be redacted. More...
 
 removeAllAnnot ()
 Remove all annotations from the current page. More...
 
 removeAnnotById (id)
 Remove an annotation by ID from the current page. The ID can be obtained by Annot::getUniqueID(). More...
 
 reverseDeviceOffset (offset, scale=1)
 Convert PDF device page offset to PDF page offset. More...
 
 reverseDevicePoint (pointer, scale=1)
 Transform PDF page point device coordinate to PDF page coordinate. More...
 
 reverseDeviceRect (pdfRect, scale=1)
 Transform PDF page device rectangle to PDF page rectangle. More...
 
 setRotation (rotation)
 

Detailed Description

PDF page object

Member Function Documentation

◆ addAnnot()

PDFPage::addAnnot (   annotJson)
inline

Add an annotation into the current page. This method may add an annotation along with an associated annotation like popup.

Parameters
annotJson{object} - JSON object which indecate annotation's properties.
annotJson.type{String} The type of annotation to be added.{all}//type:1.highlight 2.strikeout 3.underline 4.squiggly 5.caret 6.text 7.fileattachment 8.freetext 9.ink 10.line 11.link 12.circle 13.square 14.polygon 15.polyline 16.sound 17.stamp 18.redact 19.psink 20.movie 21.widget 22.screen 23.printermark 24.trapnet 25.watermark
annotJson.rect{Object} Rectangle of the new annotation.{all}
annotJson.rect.left{Number} The x-coordinate of the input left-bottom corner.
annotJson.rect.bottom{Number} The y-coordinate of the input left-bottom corner.
annotJson.rect.right{Number} The x-coordinate of the input right-top corner.
annotJson.rect.top{Number} The y-coordinate of the input right-top corner.
[annotJson.buffer]{Uint8Array} The buffer of file.{fileattachment,screen}
[annotJson.calloutLinePoints]{Array} Only when the intent name of a free text annotation is "FreeTextCallout", this free text annotation can have callout line points property, and this property has effect on this kind of free text annotation's appearance.{freetext}[optional]
[annotJson.color]{String} New border color to be set.Format: 0xRRGGBB.{all}[optional]
[annotJson.contents]{String} New content string to be set.{all}[optional]
[annotJson.coords]{Array} For a text markup annotation, quadrilaterals are required. This property has effect on text markup annotation's appearance. After setting new quadrilaterals, rectangle of current text markup annotation will be updated as well.{textmarkup}(required)
[annotJson.creationTimestamp]{Timestamp} Set creation date time.{markup}[optional]
[annotJson.date]{Timestamp} Set last modified date time.{all}[optional]
[annotJson.dicts]{Object} Set annotation's dictionary object.{all}[optional]
[annotJson.endCharIndex]{Number} For a text markup annotation, index of the end character.{textmarkup}[optional]
[annotJson.endPoint]{Object} Set the end point of line.{x: number, y: number}{line}[optional]
[annotJson.endPoint.x]{Number} The value of the X-axis in the end point.{line}[optional]
[annotJson.endPoint.y]{Number} The value of the Y-axis in the end point.{line}[optional]
[annotJson.endStyle]{Number} Set line ending style of the end point.0:"None",1:"Square",2:"Circle",3:"Diamond",4:"OpenArrow",5:"ClosedArrow",6:"Butt",7:"ROpenArrow",8:"RClosedArrow",9:"Slash".{line}[optional]
[annotJson.fileName]{String} The file name to be set. It should not be an empty string.{fileattachment,screen}
[annotJson.icon]{String} Set icon name.{stamp}[optional]
[annotJson.iconCatagory]{String} Set stamp icon's catagory.{stamp}[optional]
[annotJson.inkList]{Array} Set ink list data.If type is "ink", it should not be an empty.{ink}
[annotJson.intent]{String} Set intent name.{markup}[optional]
[annotJson.multiBuffer]{Uint8Array} The buffer of Media.{screen}
[annotJson.name]{String} New unique ID string to be set.{all}[optional]
[annotJson.noPopup]{Boolean} If true, no popup is generated,else popup is generated.{markup}[optional]
[annotJson.opacity]{Number} Set opacity value.{markup}[optional]
[annotJson.startCharIndex]{Number} For a text markup annotation,Index of the start character.{textmarkup}[optional]
[annotJson.startStyle]{Number} Set line ending style of the start point.0:"None",1:"Square",2:"Circle",3:"Diamond",4:"OpenArrow",5:"ClosedArrow",6:"Butt",7:"ROpenArrow",8:"RClosedArrow",9:"Slash".{line}[optional]
[annotJson.startPoint]{Object} Set the start point of line.{x: number, y: number}{line}[optional]
[annotJson.startPoint.x]{Number} The value of the X-axis in the start point.{line}[optional]
[annotJson.startPoint.y]{Number} The value of the Y-axis in the start point.{line}[optional]
[annotJson.style]{number} New border style to be set.{all}[optional] //solid: 0, dashed: 1, underline: 2, beveled: 3, inset: 4, cloudy: 5
[annotJson.subject]{String} Set subject string.If the value is "replace," that means that this is a Replace annotation.{markup}[optional]
[annotJson.title]{String} Set title string.{markup}[optional]
[annotJson.vertexes]{Array} Set vertexes.{polyline,polygon}[optional]
Returns
{Promise.<Array[Annot]>} - An Annot array of new added annotations.

◆ addAnnotGroup()

PDFPage::addAnnotGroup (   annotJsons,
  headerIndex 
)
inline

Add a group annotation into the current page. This method may add an annotation along with an associated annotation like popup.

Parameters
annotJsons- An array of annotations json.
headerIndex- Index of header annotation.
Returns
{Promise.<Array[Annot]>}
See also
PDFPage::addAnnot

◆ addImage()

PDFPage::addImage (   imageBuffer,
  rect 
)
inline

Add the image to page.

Parameters
imageBuffer{Uint8Buffer} - Image ArrayBuffer.
rect{PDFRect} - Image Rect. {left:number,right:number, top: number, bottom: number}
Returns
{Promise.<boolean>} - success flag.

◆ addWatermark()

PDFPage::addWatermark (   data)
inline

Add a page watermark.

Parameters
watermarkConfig{Object} - Page watermarking configuration. Example:
{
type:"text",
text:"This is a watermark",
watermarkSettings:{
position:"TopLeft",
offsetX:0,
offsetY:0,
scaleX:1,
scaleY:1,
rotation:45,
opacity:100
},
watermarkTextProperties:{
font:2,
fontSize:20,
color:0x000000,
fontStyle:"normal",
lineSpace:10,
alignment:"center"
}
};
watermarkConfig.type- {String} -
1."text" represents a text type watermark.
2."bitmap" represents the image type watermark.
watermarkConfig.text{String} - Text type watermark string.If type is "text".
watermarkConfig.bitmap{Uint8Array} - Image type watermark buffer.If type is "bitmap".
watermarkConfig.watermarkSettings{Object} - watermark -related configuration.
watermarkConfig.watermarkSettings.position{String} - The default value is "Center".
1."TopLeft":Position: top left.
2."TopCenter":Position: top center.
3."TopRight":Position: top right.
4."CenterLeft":Position center left.
5."Center":Position: center.
6."CenterRight":Position: center right.
7."BottomLeft":Position: bottom left.
8."BottomCenter":Position: bottom center.
9."BottomRight":Position: bottom right.
watermarkConfig.watermarkSettings.offsetX{Number} - Horizontal offset.The default value is 0.
watermarkConfig.watermarkSettings.offsetY{Number} - Vertical offset.The default value is 0.
watermarkConfig.watermarkSettings.flags{Number} - Combination of following value. The default value is 2.
1."0":If set, the watermark will be a part of page content when inserted to a PDF page.
2."1":If set, the watermark will be an annotation when inserted to a PDF page.
3."2":If set, show watermark above other page content.
4."4":If set, do not print a watermark.
5."8":If set, do not display a watermark.
watermarkConfig.watermarkSettings.scaleX{Number} - Horizontal scale coefficient.The default value is 1.
watermarkConfig.watermarkSettings.scaleY{Number} - Vertical scale coefficient.The default value is 1.
watermarkConfig.watermarkSettings.rotation{Number} - Rotation angle in degrees.The default value is 45.
watermarkConfig.watermarkSettings.opacity{Number} - Opacity in percents. Valid range: from 0 to 100. 0 for fully transparent and 100 for fully opaque.The default value is 100.
watermarkConfig.watermarkTextProperties{Object} - Configuration for text watermarking.
watermarkConfig.watermarkTextProperties.font{Number} - A valid Font object used for the text.The default value is "0".
1."0":Standard font: Courier.
2."1":Standard font: Courier-Bold.
3."2":Standard font: Courier-BoldOblique, Bold italic.
4."3":Standard font: Courier-Oblique, Italic.
5."4":Standard font: Helvetica.
6."5":Standard font: Helvetica-Bold.
7."6":Standard font: Helvetica-BoldOblique, Bold italic.
8."7":Standard font: Helvetica-Oblique, Italic.
9."8":Standard font: Times-Roman.
10."9":Standard font: Times-Bold.
11."10":Standard font: Times-BoldItalic.
12."11":Standard font: Times-Italic.
13."12":Standard font: Symbol.
14."13":Standard font: ZapfDingbats.
watermarkConfig.watermarkTextProperties.fontSize{Number} - font size.The default value is 20.
watermarkConfig.watermarkTextProperties.color{Number} - <Hexadecimal> font color.The default value is "0x000000".
watermarkConfig.watermarkTextProperties.fontStyle{String} - The default value is "normal".
1."normal":Watermark font style: normal.
2."underline":Watermark font style: with underline.
watermarkConfig.watermarkTextProperties.lineSpace{Number}- line spacing.The default value is 10.
watermarkConfig.watermarkTextProperties.alignment{String}-The default value is "center".
1."left":Left alignment.
2."center":Center alignment.
3."right":Right alignment.

◆ flatten()

PDFPage::flatten (   option)
inline

Flatten all annotations and interactive form fields in a Page.

Parameters
option{int} - Flatten type: e_FlattenAll = 0, e_FlattenNoAnnot = 0x0001, e_FlattenNoFormControl = 0x0002. 0x0000 means flatten all annotations and interactive form. 0x0001 means flatten all interactive form. 0x0002 means flatten all annotations.
Returns
{Promise.<boolean>} - success flag.

◆ getAnnotCount()

PDFPage::getAnnotCount ( )
inline

Gets the total amount of all annotations in a specified page.

Returns
{number} - the total numebr of page annotations

◆ getAnnotIdAtDevicePoint()

PDFPage::getAnnotIdAtDevicePoint (   point,
  tolerance,
  matrix 
)
inline

Get the specified position of an annotation in device page coordinate.

Parameters
[x,y]{[number, number]} - The specified position, in device coordinate system.
tolerance{number} - The tolerance value. Valid range: 0.0f to 30.0f.
matrix{Matrix} - The device matrix such as page.getDeviceMatrix();
Returns
{Promise<string>} - Annotation's ID
function example (scale) {
var matrix = page.getDeviceMatrix();
matrix.scale(scale, scale);
return page.getAnnotIdAtDevicePoint([x, y], tolerance, [matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f]);
}

◆ getAnnots()

PDFPage::getAnnots ( )
inline

Get an array of all annotations in a page.

Returns
{Promise.<Annot[]>} - Annotation objects of page annotations.

◆ getAnnotsByIdArray()

PDFPage::getAnnotsByIdArray (   ids)
inline

Get an array of page annotation ID which can be obtained by Annot::getUniqueID().

Parameters
ids{Array[string]} - Specifies annotations ID.
Returns
{Promise.<Annot[]>} - Annot objects of page annotations.

◆ getAnnotTree()

PDFPage::getAnnotTree ( )
inline

Get a structrual tree of all annotations in a specified page.

Returns
Promise<Annot[]> - annotations in this page excluding popups, replies and state annotations.

◆ getCharInfoAtPoint()

PDFPage::getCharInfoAtPoint (   point,
  tolerance = 0 
)
inline

Get character information at a specified position, in PDF coordination system.

Parameters
[x,y]{[number, number]} - The specified position, in PDF coordinate system.
tolerance{number} - Tolerance value. Valid range: 0.0f to 30.0f.
Returns
{Promise.<object>} - {charIndex:number, left:number, right:number, top:number, bottom:number}

◆ getDeviceMatrix()

PDFPage::getDeviceMatrix ( )
inline

Get the device matrix for the page.

Returns
{Matrix} - Page's device displaying matrix.

◆ getDevicePoint()

PDFPage::getDevicePoint (   point,
  scale = 1 
)
inline

Convert PDF coordinates to device coordinates for the page.

Parameters
[x,y]{[number,number]} - Specifies PDF page point coordinate.
[scale=1]{number} - Indecate magnification
Returns
[x,y] {[number,number]} - Device point coordinate.

◆ getDeviceRect()

PDFPage::getDeviceRect (   pdfRect,
  scale = 1,
  rotate = 0 
)
inline

Convert PDFRect to deviceRect.

Parameters
pdfRect{PDFRect} - PDF Rect. {left:number,right:number, top: number, bottom: number}
[scale=1]{number} - Rect magnification
[rotate=0]{number} - Rotation Angle. Only support multiples of 90. The other values default to 0.
Returns
{DeviceRect} - Device Rect. {left:number,right:number, top: number, bottom: number}

◆ getHeight()

PDFPage::getHeight ( )
inline

Get page height.

Returns
{number} - Page's height with point unit.

◆ getIndex()

PDFPage::getIndex ( )
inline

Get page's index.

Returns
{number} - Page index.

◆ getMarkupAnnots()

PDFPage::getMarkupAnnots ( )
inline

Get only markup annotations in the current page.

Returns
Promise<Markup[]> - All markup annotations excluding popup, replies and states in this page.

◆ getPDFDoc()

PDFPage::getPDFDoc ( )
inline

Get the document object.

Returns
{PDFDoc} - Document object which own this page.

◆ getPDFMatrix()

PDFPage::getPDFMatrix ( )
inline

Get page matrix.

Returns
{Matrix} - Page's displaying matrix.

◆ getRotation()

PDFPage::getRotation ( )
inline

Get page rotation angle.

Returns
{number} - get page rotation, one of these values list below:
0: for no rotateion,
1: for rotate 90 degree,
2: for rotate 180 degree,
3: for rotate 270 degree,

◆ getRotationAngle()

PDFPage::getRotationAngle ( )
inline

Get page rotation angle.

Returns
{number} - get page rotation, one of these values list below:
0: for no rotateion,
90: for rotate 90 degree,
180: for rotate 180 degree,
270: for rotate 270 degree,

◆ getTextRectsAtRect()

PDFPage::getTextRectsAtRect (   rect)
inline

Get page text rectangles in specified rectangle.

Parameters
rect{PDFRect} - Specifies page rectangle in PDF coordination system.
Returns
{Promise.<PDFRect[]>} - The text rectangles in PDF coordination system.

◆ getTextSearch()

PDFPage::getTextSearch (   pattern,
  flags 
)
inline

Get PageTextSearch with specified pattern and flags.

Parameters
pattern{String}
flags{number} - Refer to the following values, which can be one or a combination of these values.
0: No special searching options.
1: If set, match the case of keyword when searching.
2: If set, match the whole word of keyword when searching.
4: If set, match the key word consecutively when searching. For example, "CC" will be matched twice in "CCC".
Returns
{Promise.<PasgeTextSearch>|*} - PageTextSearch

◆ getThumb()

PDFPage::getThumb ( )
inline

Get the PDF stream of "Thumb".

Returns
{Promise.<Object>} - {buffer: Uint8Array , width: int, height: int}

◆ getWidth()

PDFPage::getWidth ( )
inline

Get page width.

Returns
{number} - Page width with point unit.

◆ markRedactAnnot()

PDFPage::markRedactAnnot (   rects,
  annot 
)
inline

Mark page contents (text object, image object, and path object) which are to be redacted.

Parameters
rects- Specify areas in the page to be marked. It should not be an empty array. All the input rectangles will be treated as one redact annotation.
Returns
{Promise.<Array[Annot]>} - An Annot array of new added annotations.

◆ removeAllAnnot()

PDFPage::removeAllAnnot ( )
inline

Remove all annotations from the current page.

Returns
{Promise.<Array[Annot]>}

◆ removeAnnotById()

PDFPage::removeAnnotById (   id)
inline

Remove an annotation by ID from the current page. The ID can be obtained by Annot::getUniqueID().

Parameters
id{string} - An ID string of the annotation which will be removed.
Returns
{Promise.<Array[Annot]>}

◆ reverseDeviceOffset()

PDFPage::reverseDeviceOffset (   offset,
  scale = 1 
)
inline

Convert PDF device page offset to PDF page offset.

Parameters
[dx,dy]{[number, number]} - Device offset.
[scale=1]{number} - Indecates magnification.
Returns
[dx,dy] {[number,number]} - PDF page offset.

◆ reverseDevicePoint()

PDFPage::reverseDevicePoint (   pointer,
  scale = 1 
)
inline

Transform PDF page point device coordinate to PDF page coordinate.

Parameters
[x,y]{[number, number]} - Specifies device point coordinate
[scale=1]{number} - Indecates magnification.
Returns
[x,y] {[number,number]} - PDF page point coordinate.

◆ reverseDeviceRect()

PDFPage::reverseDeviceRect (   pdfRect,
  scale = 1 
)
inline

Transform PDF page device rectangle to PDF page rectangle.

Parameters
pdfRect{DeviceRect} - Indecates PDF page device rectangle
[scale=1]{number} - Indecates magnification.
Returns
{PDFRect} - PDF page rectangle

◆ setRotation()

PDFPage::setRotation (   rotation)
inline

Set page rotation.

Parameters
rotation{number} - 0: 0deg, 1: 90deg, 2: 180deg, 3 270deg;
examples:
function example (pdfPage, pdfViewer, engineEvent) {
pdfPage.setRotation(1).then(function () {
// rotation change success
});
pdfViewer.getEventEmitter().on(engineEvent.pageRotationChange, function (pdfPage, newRotation, oldRotation) {
// rotation change success
)
}

Foxit Software Corporation Logo
@2019 Foxit Software Incorporated. All rights reserved.