| FoxitPDFSDKforWeb v11.0.5 Archives Foxit PDF SDK for Web

Public Member Functions | List of all members
PDFDoc Class Reference
PDF
Inheritance diagram for PDFDoc:

## Public Member Functions
| addAnnot (pageIndex, annotJson)
| Add an annotation into a specified page. [Support in Server] More...
| addAnnotGroup (pageIndex, annotJsons, headerIndex)
| Add a group annotation [Support in Server] More...
| addAnnots (annotJsonArray)
| Add annotations into the current document. More...
| addEmbeddedFile (key, fileSpec)
| Add an embedded attachment (as file specification object) with new key name. More...
| addHeaderFooter (headerFooter)
| Add new header-footer. More...
| addLayerGraphicObject (layerNodeId, pageIndex, graphicObjectIndex)
| Add a new graphics object to the layer node. More...
| addLayerNode (parentLayerId, {index, name, hasLayer=false}={})
| Add a new layer node as a child for the specified layer node. More...
| addPagingSealSignature (info)
| Add a paging seal signature field into specified pages. More...
| addWatermark (data)
| Add watermark. More...
| applyRedaction ()
| Apply redaction in marked areas: remove the text or graphics under marked areas permanently. [Support in Server] More...
| autoRecognitionForm (options={})
| Auto recognition form for PDF documents. More...
| checkPassword (password)
| Check the type of a specified password. More...
| drmEncrypt (drmOptions)
| exportAnnotsToFDF (fileType=0, annots=null)
| Export annotation data in a document to a file. Not support Screen Image, Link and Sound. [Support in Server] More...
| exportAnnotsToJSON (annotArray)
| Export the document's annotation data to Json. Not support Screen Image, Link and Sound. [Support in Server] More...
| exportFormToFile (fileType=FileFormat.fdf)
| Export document form data to file. More...
| exportXFAToFile (fileType=FileFormat.xdp)
| Export document form data to file. More...
| extractPages (pageRange)
| Export the given page(s) from the current document. More...
| flatten (option)
| Flatten all annotations and interactive form fields in a PDF. More...
| getAdditionalAction ()
| Retrives the additional action object. More...
| getAllBoxesByPageIndex (index)
| Gets all boxes by specified page index. More...
| getAllPagingSealSignatures (pagingSigObjNum)
| Get all paging seal signature object numbers. More...
async | getAnnots ()
| Get an array of all annotations of the current document. [Support in Server] More...
| getComparisonFilterCountSummary ()
| Get the count information for each item of the comparison result; The statistical result is the total number of document difference types, but each difference occurs in pairs, so the number of differences is 1 / 2 of the total. More...
| getEmbeddedFile (key)
| Get the embedded file by the specified key name. More...
| getEmbeddedFileNames ()
| Get the embedded file list. More...
| getFile ({ flags=0, fileName=this.getFileName(), progressHandler=noop }={ flags:0, fileName:this.getFileName(), progressHandler:noop })
| Export the PDF document object to the File object. More...
| getFontsInfo ()
| Get fonts info. More...
| getHeaderFooter ()
| Get HeaderFooter of document. More...
| getId ()
| Gets the id of the PDF document [Support in Server] More...
| getInfo ()
| Get the information dictionary of the pdf document. More...
| getLayerNodesJson (force=false)
| Get the document's layer nodes. More...
| getMetadata ()
| Get metadata of PDF document. [Support in Server] More...
| getOpenAction ()
| Gets the hierarchical structure data of the document's open action. More...
| getPageAnnots (index)
| Get all annotations in a specified page by page index. [Support in Server] More...
| getPageByIndex (index)
| Get the document page [Support in Server] More...
| getPageCount ()
| Gets the number of document pages [Support in Server] More...
| getPageLabels (pageIndexes)
| Get the page labels of the pdf document. More...
| getPasswordType ()
| Get the type of current used password. [Support in Server] More...
| getPDFForm ()
| Get form object of PDF Document. [Support in Server] More...
| getPermissions ()
| Get user access permissions. [Support in Server] If it is the owner of the document, then 4294967292 is put back to indicate full permissions. . More...
| getStream (writeChunk, flag=0, endAllOperations)
| Gets a PDF file stream that can be used to download documents [Support in Server] More...
| getText (pages)
| Gets the text content of the specific pages. The type of XFA Documents is not supported. More...
| getTextSearch (pattern, flags)
| Get text search object. [Support in Server] More...
| getUserPermissions ()
| getViewPreference ()
| Get the view preference of the document. More...
| getWordCount ()
| Get the document's word count. More...
| has3DAnnots ()
| Whether the document has 3D annotation. More...
| hasForm ()
| Call this function to determine whether the document contains pdf form. More...
| hasOwnerPassword ()
| Judge whether the owner password exists. More...
| importAnnotsFromFDF (fdf, escape=true)
| Import data from an FDF file specified by array buffer. [Support in Server] More...
| importAnnotsFromJSON (annotsJson)
| Import data from Json. [Support in Server] More...
async | importFormFromFile (file, format, encoding='UTF-8')
| Import form data from an FDF file specified by array buffer. More...
| importXFAFromFile (file, format=FileFormat.xdp)
| Export document form data to file. More...
| insertBlankPages (pageRange, width, height)
| Insert a new blank PDF page to the specified pages, by indexes. More...
| insertPage (pageIndex, width, height)
| Insert a new blank PDF page to document, by index. [Support in Server] More...
| insertPages ({destIndex, file, password="", flags=0, layerName="", startIndex, endIndex})
| Start to import pages from another PDF document. More...
| isCompareDoc ()
| Used to determine whether the PDF document is a comparison result document. More...
| isDocModified ()
| Call this function to determine whether the document is modified if modified return true, false otherwise. [Support in Server] More...
| isLinearized ()
| Call this function to determine whether the document is represented in linearized (fast web view) format. More...
| loadThumbnail (options)
| Loads a thumbnail for a particular page number. More...
| makeRedactByPages (pages)
| Mark pages which are to be redacted. More...
| mergePDFDoc (options)
| Merge pages from another PDF document. More...
| movePagesTo (pageRange, destIndex=0)
| Move the specified pages to a new index position. More...
| movePageTo (pageIndex, destIndex)
| Move a specified page to a new index position. [Support in Server] More...
| removeAllEmbeddedFiles ()
| Remove all files embedded in the current PDF document. More...
| removeAllWatermarks ()
| removeEmbeddedFileByName (name)
| Remove the embedded file by the specified key name. More...
| removeHeaderFooter ()
| Remove all headers and foonters of document. More...
| removeHiddenData (types=[])
| Remove hidden data. More...
| removeLayerGraphicObject (layerNodeId, pageIndex, graphicObjectIndex)
| Remove a graphics object from the layer node. More...
| removeLayerNode (layerNodeId)
| Remove of a specified layer node. More...
| removeOpenAction ()
| Removes the document's open action. After removal, the document will no longer perform any actions when opened. More...
| removePage (pageIndex)
| Remove a PDF page by page index. [Support in Server] More...
| removePages (pageRange)
| Remove the specified pages by page indexes. More...
| removePagingSealSignature (info)
| Remove paging seal signature. All signature associated with paging seal signature will be removed. More...
| removeSignature (fieldName)
| Remove signature. More...
| rotatePages (pageRange, rotation)
| Set the specified pages rotation. More...
| sanitize ()
| Sanitize Document removes metadata and other hidden data. More...
| searchText (pages, words, options={})
| Search the specified text on the specified page. More...
| setEmbeddedFile (key, fileSpec)
| Set an embedded attachment (as file specification object) for a specified key. More...
| setLayerNodeVisible (layerId, visible)
| Set the visibility of a specified layer node. More...
| setMetadataValue (key, value)
| Set metadata value. More...
| setOpenAction (actionType, actionData)
| Sets an action that will be executed automatically when the document is opened. More...
| setPagesBox ({ indexes, width, height, offsetX, offsetY, boxes, removeWhiteMargin }={})
| Set pages box. More...
| setPasswordAndPermission (userPassword, ownerPassword, permission=0xfffffffc, cipher=cipherType.AES256, isEncryptMetadata=true)
| Set document password and permission. More...
| sign (signInfo, DigestSignHandler)
| Sign the current document by the specified signature information. More...
| updateHeaderFooter (headerFooter)
| Modify header or footer of documents. If there is no header or footer, this function will add one. More...
| updatePagingSealInfo (info)
| Update paging seal signature. More...
| updatePagingSealSignature (info)
| Update paging seal signature. More...
| verifySignature (field, VerifyHandler)
| Verify signature's status. More...
Public Member Functions inherited from Disposable
| addDestroyHook (...hooks)
| Add a function to destroyHooks list, which will be called during destroy. More...
| destroy ()
| ownsTo (owner)
| Establishes an ownership relationship where this instance will be destroyed when the owner is destroyed. Additionally, the owner will be automatically removed from the destroyHooks list when this instance is destroyed. More...

## Detailed Description

PDF document object

## Member Function Documentation

## ◆ addAnnot()

PDFDoc::addAnnot | ( |  | pageIndex,
|  |  | annotJson
| ) |  |
| inline

Add an annotation into a specified page. [Support in Server]

Parameters

  pageIndex | number - Specifies target page.
  annotJson | object - Annotation's json object.

Returns
  Promise<Annot[]> -

See also
  PDFPage::addAnnot

## ◆ addAnnotGroup()

PDFDoc::addAnnotGroup | ( |  | pageIndex,
|  |  | annotJsons,
|  |  | headerIndex
| ) |  |
| inline

Add a group annotation [Support in Server]

Parameters

  pageIndex | number - Specifies target page.
  annotJsons | object - Annotation's json object.
  headerIndex | number - Indicates the header annotation's index.

Returns
  Promise<Annot[]> - Annotations added as a group.

See also
  PDFPage::addAnnotGroup

## ◆ addAnnots()

PDFDoc::addAnnots | ( |  | annotJsonArray | ) |
| inline

Add annotations into the current document.

Note
  If add a stamp annot with default annotation icon(`icon` and `iconCategory` are specified), please call PDFViewer.initAnnotationIcons(icons) to set default annotation icons.
  PDFViewer.initAnnotationIcons(icons) is not support in Server.

Parameters

  annotJsonArray | object[] - The collection of annotations to be added. JSON object which indicates annotation's properties.
  annotJsonArray[].page | number - The page number to be added.
  [annotJsonArray[].replies] | object[]|string[] - JSON object that indicates the reply property of the comment. A string that indicates the comment's reply content.
  [annotJsonArray[].replies[].name] | string - New unique ID string to be set.
  [annotJsonArray[].replies[].contents] | string - New content string to be set.
  [annotJsonArray[].replies[].flags] | number - The annotation flags. Please refer to values starting from Annot_Flags.invisible and this would be one or a combination of these values.
  [annotJsonArray[].replies[].title] | string - Set title string. Set creation date time.
  [annotJsonArray[].replies[].creationTimestamp] | number - Set creation date time.
  [annotJsonArray[].replies[].date] | number - Set last modified date time.
  [annotJsonArray[].states] | object[]|string[] - JSON object that indicates the state property of the comment. A string that indicates the comment's state. Look at MARKUP_ANNOTATION_STATE.
  [annotJsonArray[].states[].state] | string - A string that indicates the comment's state. Look at MARKUP_ANNOTATION_STATE.
  [annotJsonArray[].states[].name] | string - New unique ID string to be set.
  [annotJsonArray[].states[].flags] | number - The annotation flags. Please refer to values starting from Annot_Flags.invisible and this would be one or a combination of these values.
  [annotJsonArray[].states[].title] | string - Set title string. Set creation date time.
  [annotJsonArray[].states[].creationTimestamp] | number - Set creation date time.
  [annotJsonArray[].states[].date] | number - Set last modified date time.
  [annotJsonArray[].groupElements] | object[] - The child of an annotation group.
  [annotJsonArray[].type] | Annot_Type - The type of annotation to be added. If this is a new Annotation, this is a required field. Support type: Annot_Type::highlight Annot_Type::strikeOut Annot_Type::underline Annot_Type::squiggly Annot_Type::caret Annot_Type::text Annot_Type::fileAttachment Annot_Type::freeText Annot_Type::ink Annot_Type::line Annot_Type::link Annot_Type::circle Annot_Type::square Annot_Type::polygon Annot_Type::polyline Annot_Type::stamp Annot_Type::screen
  [annotJsonArray[].rect] | object - Rectangle of the new annotation. If this is a new Annotation, this is a required field.
  [annotJsonArray[].rect.left] | number - The x-coordinate of the input left-bottom corner.
  [annotJsonArray[].rect.bottom] | number - The y-coordinate of the input left-bottom corner.
  [annotJsonArray[].rect.right] | number - The x-coordinate of the input right-top corner.
  [annotJsonArray[].rect.top] | number - The y-coordinate of the input right-top corner.
  [annotJsonArray[].borderInfo] | object - set border information. [optional]
  [annotJsonArray[].borderInfo.width] | number - Border width. [optional]
  [annotJsonArray[].borderInfo.style] | number - Border style.Style {0:"Solid", 1:"Dashed", 2:"UnderLine", 3:"Beveled",4:"Inset", 5:"Cloudy"}. [optional] If the boder style is set to the unsupporetd type annotation, It will change to set border style as 'Solid' by default internally. For details: 0 ("Solid"): Solid border. 1 ("Dashed"): This is only useful for link, free text, line, square, circle, polygon, polyline and screen annotation. 2 ("UnderLine"): This is only useful for link annotation. 3 ("Beveled"): Currently, It does not support the annotation appearance of this border style. 4 ("Inset"): Currently, It does not support the annotation appearance of this border style. 5 ("Cloudy"): This is only useful for free text, square, circle, and polygon annotations.
  [annotJsonArray[].borderInfo.cloudIntensity] | number - Intensity of the cloudy effect.Only useful when parameter style is "Cloudy". [optional] Valid value range: 0 to 2. 0 means no cloudy border effect. If the value is below 0, it will have the same effect as value 0. If the value is above 2, it will have the same effect as value 2.
  [annotJsonArray[].borderInfo.dashPhase] | number - Dash phase.Only useful when parameter style is "Dashed". [optional]
  [annotJsonArray[].borderInfo.dashes] | number[] - A dash array that represents the dash patterns.Only useful when parameter style is "Dashed". [optional]
  [annotJsonArray[].alignment] | number - Set alignment value. Alignment { 0:"AlignmentLeft", 1:"AlignmentCenter", 2:"AlignmentRight" } [optional] This parameter is valid only when the type is freetext.
  [annotJsonArray[].buffer] | Uint8Array - The buffer of file. [optional] This parameter is valid only when the type is fileattachment and screen.
  [annotJsonArray[].calloutLinePoints] | number[] - 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. [optional] This parameter is valid only when the type is freetext.
  [annotJsonArray[].calloutLineEndingStyle] | number - 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. Please refer to Ending_Style. {freetext && FreeTextCallout}[optional]
  [annotJsonArray[].color] | string - New border color to be set.Format: 0xRRGGBB. [optional]
  [annotJsonArray[].contents] | string - New content string to be set. [optional] If annotJsonArray[].richText is set and annotJson.type equal to freetext, this parameter is invalid.
  [annotJsonArray[].coords] | Array<{left:number;top:number;right:number;bottom:number;}> - 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.In order to startCharIndex/endCharIndex priority. [optional] This parameter is valid only when the type is textmarkup.(required)
  [annotJsonArray[].creationTimestamp] | number - Set creation date time. [optional] This parameter is valid only when the type is markup.
  [annotJsonArray[].date] | number - Set last modified date time. [optional]
  [annotJsonArray[].dicts] | object - Set annotation's dictionary object. [optional]
  [annotJsonArray[].defaultAppearance] | object - Set annotation's default appearance. [optional] If annotJsonArray[].richText is set and annotJson.type equal to freetext, this parameter is invalid. This parameter is valid only when the type is freetext.
  [annotJsonArray[].defaultAppearance.textColor] | number - Set annotation's default text color (0x**RRGGBB). [optional] This parameter is valid only when the type is freetext.
  [annotJsonArray[].defaultAppearance.textSize] | number - Set annotation's default text size. [optional] This parameter is valid only when the type is freetext.
  [annotJsonArray[].endCharIndex] | number - For a text markup annotation, index of the end character. [optional] This parameter is valid only when the type is textmarkup. Setting both annotJsonArray[].startCharIndex and annotJsonArray[].endCharIndex will calculate the value of annotJsonArray[].coords internally and replace it.
  [annotJsonArray[].endPoint] | object - Set the end point of line.{x: number, y: number} [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].endPoint.x] | number - The value of the X-axis in the end point. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].endPoint.y] | number - The value of the Y-axis in the end point. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].flags] | number - The annotation flags. Please refer to values starting from Annot_Flags.invisible and this would be one or a combination of these values. The default value is 0. It will also not print.
  [annotJsonArray[].measure] | object - Set the measure of line. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.unit] | string - Set the label for displaying the units for measuring. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.ratio] | object - Set the scale ratio for measuring. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.ratio.userSpaceValue] | number - Set the ratio value in user space. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.ratio.userSpaceUnit] | string - Set the ratio unit in user space. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.ratio.realValue] | number - Set the ratio value in real space. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].measure.ratio.realUnit] | string - Set the ratio unit in real space. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].endStyle] | Ending_Style - Set line ending style of the end point. Please refer to Ending_Style. [optional] This parameter is valid only when the type is circle, line, polyline, polygon and square.
  [annotJsonArray[].fileName] | string - The file name to be set. This is mandatory when the multiBuffer parameter exists. [optional] This parameter is valid only when the type is fileattachment and screen.
  [annotJsonArray[].contentType] | string - Set the content type (MIME type) of the media data. This is mandatory when the multiBuffer parameter exists. [optional] This parameter is valid only when the type is screen.
  [annotJsonArray[].fillColor] | string - New fill color to be set. Format: 0xRRGGBB. 0 for transparent. [optional] This parameter is valid only when the type is freetext, circle, square and polygon.
  [annotJsonArray[].iconInfo] | object - Specifies the icon of stamp. Attention: this property will override "icon" and "iconCategory" properties. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].iconInfo.annotType] | string - The type of supported annot. Currently, it must be "stamp". [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].iconInfo.category] | string - Category which the icon is collected. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].iconInfo.name] | string - The name of icon. Only ascii characters are available. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].iconInfo.fileType] | string - The file type of icon. One of 'bmp', 'jpg', 'jpeg', 'png', 'webp'. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].iconInfo.url] | string - The url of icon. It supports HTTP, file, blob url and base64 url. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].icon] | string - Set icon name. The name of icon. Only ascii characters are available. [optional] This parameter is valid only when the type is stamp. If annotJsonArray[].iconInfo.name is set and annotJson.type equal to stamp, this parameter is invalid.
  [annotJsonArray[].iconCategory] | string - Set stamp icon's category. [optional] This parameter is valid only when the type is stamp.
  [annotJsonArray[].inkList] | Array<{x:number;y:number;type:1|2|3;}> - Set ink list data.If type is "ink", it should not be an empty. [optional] This parameter is valid only when the type is ink.
  [annotJsonArray[].intent] | string - Set intent name. [optional]. Please refer to IMarkupAnnotationSummary::intent This parameter is valid only when the type is markup.
  [annotJsonArray[].multiBuffer] | Uint8Array - The buffer of Media. [optional] This parameter is valid only when the type is screen.
  [annotJsonArray[].name] | string - New unique ID string to be set. [optional]
  [annotJsonArray[].noPopup] | boolean - If true, no popup is generated,else popup is generated. [optional] This parameter is valid only when the type is markup.
  [annotJsonArray[].opacity] | number - Set opacity value.only 0~1 is valid. [optional] This parameter is valid only when the type is markup.
  [annotJsonArray[].startCharIndex] | number - For a text markup annotation,Index of the start character. [optional] This parameter is valid only when the type is textmarkup. Setting both annotJsonArray[].startCharIndex and annotJsonArray[].endCharIndex will calculate the value of annotJsonArray[].coords internally and replace it.
  [annotJsonArray[].startStyle] | number - Set line ending style of the start point. Please refer to Ending_Style. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].startPoint] | object - Set the start point of line.{x: number, y: number} [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].startPoint.x] | number - The value of the X-axis in the start point. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].startPoint.y] | number - The value of the Y-axis in the start point. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].length] | number - Set line's leader line length. [optional] This parameter is valid only when the type is line.
  [annotJsonArray[].styleFillColor] | string - Set fill color for ending styles. New fill color to be set. Format: 0xRRGGBB, 0 for transparent, otherwise alpha will be set to 0xFF. [optional] This parameter is valid only when the type is polyline and line.
  [annotJsonArray[].subject] | string - Set subject string.If the value is "replace," that means that this is a Replace annotation. [optional] This parameter is valid only when the type is markup.
  [annotJsonArray[].title] | string - Set title string. [optional] This parameter is valid only when the type is markup.
  [annotJsonArray[].vertexes] | Array<{x:number;y:number;}> - Set vertexes, Vertexes property is required for a polyline annotation. [optional] This parameter is valid only when the type is polyline and polygon.
  [annotJsonArray[].rotation] | number - Set the rotation in clockwise, Currently, only support free text, stamp, srceen annotations. for free text, srceen annotation, this should be one of these values : 0, 90, 180, 270. for stamp annotation, the value range is from 0 to 360.
  [annotJsonArray[].richText] | object[] - An array of rich text data. Now, Only support FreeText annotation.
  [annotJsonArray[].richText[].content] | string - Text string to be set as content for specified rich text. This should not be an empty string.
  [annotJsonArray[].richText[].richTextStyle] | object - The style data of a rich text string
  [annotJsonArray[].richText[].richTextStyle.font] | object - A valid font object.
  [annotJsonArray[].richText[].richTextStyle.font.name] | string - the face name of the font. If it`s a standard font, the font styles and charset will not work. The standard font are 'Courier','Courier-Bold','Courier-BoldOblique','Courier-Oblique', 'Helvetica','Helvetica-Bold','Helvetica-BoldOblique','Helvetica-Oblique','Times-Roman', 'Times-Bold','Times-BoldItalic','Times-Italic','Symbol','ZapfDingbats'. While using 'Symbol' or 'ZapfDingbats, the parameter "richTextStyle.isBold" and "richTextStyle.isItalic" will not work. If it`s a custom font, you should call PDFViewer.setJRFontMap to map the available fonts.
  [annotJsonArray[].richText[].richTextStyle.font.styles] | number - The font styles. Please refer to Font_Styles .
  [annotJsonArray[].richText[].richTextStyle.font.charset] | number - The charset of the font. Please refer to Font_Charset or Font_CIDCharset .
  [annotJsonArray[].richText[].richTextStyle.textSize] | number - Text size. It should not be negative value. 0 means text will not be shown.
  [annotJsonArray[].richText[].richTextStyle.textAlignment] | number - Alignment value. Please Refer to Alignment .
  [annotJsonArray[].richText[].richTextStyle.textColor] | number - Text color. Format: 0xRRGGBB.
  [annotJsonArray[].richText[].richTextStyle.isBold] | boolean - A boolean value which indicates whether to make text bold or not.
  [annotJsonArray[].richText[].richTextStyle.isItalic] | boolean - A boolean value which indicates whether to italicize text or not.
  [annotJsonArray[].richText[].richTextStyle.isUnderline] | boolean - A boolean value which indicates whether to underline text or not.
  [annotJsonArray[].richText[].richTextStyle.isStrikethrough] | boolean - A boolean value which indicates whether to cross text out with strike through or not.
  [annotJsonArray[].richText[].richTextStyle.cornerMarkStyle] | number - Corner mark style which can be used to make text as superscript or subscript or not as any kind of corner mark. 1 - Corner mark style: none. 2 - Corner mark style: superscript. 3 - Corner mark style: subscript.

Returns
  Promise<Annot[]> - An Annot array of new added annotations.

Since
  9.1.0

Example: If you add Annot for a group, then the group header is the primary Annot, and annotJson for other group members is placed in groupElements (not containing the primary Annot).
  // If you add Annot for a group, then the group header is the primary Annot, and annotJson for other group members is placed in groupElements (not containing the primary Annot).
  pdfDoc.addAnnots([{
  page: 0,
  type: 'strikeout',
  rect: {left: 0, right: 10, top: 500, bottom: 490},
  groupElements: [{
  type: 'caret',
  rect: {left: 0, right: 10, top: 500, bottom: 490},
  }]
  }])

Example: If you are adding a reply, distinguish between the following cases
  // 1. Append replies to Annot that will be added together. annotJson for replies is placed in replies (one-dimensional array). The new Annot is written in the usual way.
  pdfDoc.addAnnots([{
  page: 0,
  type: 'strikeout',
  rect: {left: 0, right: 10, top: 500, bottom: 490},
  replies: [{
  contents: '', // Indicates the content of the reply
  }]
  }])
  // 2. Add new replies to existing Annot. annotJson for replies is placed in replies (one-dimensional array). The Annot that is appended provides the page and name, and must not add type (to confirm that this is not the Annot that needs to be added). If the name cannot find Annot, the reply is discarded.
  pdfDoc.addAnnots([{
  page: 0,
  name: 'xxx-xxx-xxxx', // This is used to locate the append reply to the Annot. This is json for positioning purposes only. type and rect should not be passed. name is required.
  replies: [{
  content: '',
  }]
  }])
  // 3. Add a reply to a reply added together. First you need to add a new reply together, before the index in the argument array and append the reply. The reply added together needs to provide the name, and the supplementary reply needs to specify the name of the reply added together
  pdfDoc.addAnnots([{
  page: 0,
  name: 'xxx-xxx-xxxx', // This is used to locate the append reply to the Annot.
  replies: [{
  name: 'yyy-yyy-yyyy',
  content: '',
  }]
  }, {
  page: 0,
  name: 'yyy-yyy-yyyy', // This is used to locate the append reply to the Annot. 'yyy-yyy-yyyy' needs to be added to the front of the array before a new reply can be appended, otherwise the new reply will be discarded. This way, you can add replies in a tree step by step.
  replies: [{
  content: '',
  }]
  }])

Example: If you are adding a state, the state is placed in states, similar to adding a reply
  pdfDoc.addAnnots([{
  page: 0,
  type: 'strikeout',
  rect: {left: 0, right: 10, top: 500, bottom: 490},
  states: [{
  state: 'marked',
  }]
  }])

## ◆ addEmbeddedFile()

PDFDoc::addEmbeddedFile | ( |  | key,
|  |  | fileSpec
| ) |  |
| inline

Add an embedded attachment (as file specification object) with new key name.

Note: All attachments in EmbeddedFiles name tree are ordered by their keys. When a new attachment is added, Foxit PDF SDK will find a suitable place in the name tree to add it. After adding successfully, the indexes of some old keys may be changed.

Parameters

  key | string - The key name of the embedded file. If this is an empty string, the name of input fileSpec will be used as the new key. This new key should not have existed in the PDF document to which current attachments object belongs.
  fileSpec | object - The file specification object.
  [fileSpec.name] | string - The file name of the embedded file. It should not be an empty string.
  fileSpec.data | File|Blob|ArrayBuffer|TypedArray|DataView - The data of the embedded file.
  [fileSpec.description] | string - The description of the embedded file. It should not be an empty string.
  [fileSpec.creationDate] | number - The creation date of the embedded file.
  [fileSpec.modificationDate] | number - The modification date of the embedded file.

Returns
  Promise<boolean> - return true if the embedded file is added successfully, otherwise return false.

Since
  9.1.0

## ◆ addHeaderFooter()

PDFDoc::addHeaderFooter | ( |  | headerFooter | ) |
| inline

Add new header-footer.

Since
  7.2.0

A PDF document can be added header-footer sereral times. When a new header-footer is added, the old ones will not be removed but be covered by the new one if the old ones appear in the same place as new one.

Note
  It should call PDFDOC::updateHeaderFooter to modify HeaderFooter.

Parameters

  headerfooter | HeaderFooter - A valid header-footer object to be added to current document.

Returns
  Promise<object> - A null for failed or success.

## ◆ addLayerGraphicObject()

PDFDoc::addLayerGraphicObject | ( |  | layerNodeId,
|  |  | pageIndex,
|  |  | graphicObjectIndex
| ) |  |
| inline

Add a new graphics object to the layer node.

Parameters

  layerNodeId | string - The layer node id. It should not be an empty string. Please refer to getLayerNodesJson.
  pageIndex | number - The page index.
  graphicObjectIndex | number - The special graphic object index of the special page. Please refer to addGraphicsObject.

Returns
  Promise<boolean> - TRUE means success, while FALSE means failure.

Example:
  async function example (pdfDoc) {
  const layerNodes = await pdfDoc.getLayerNodesJson();
  let result = await pdfDoc.addLayerGraphicObject(layerNodes.children&&layerNodes.children[0].id,0,0);
  }

Since
  10.0.0

## ◆ addLayerNode()

PDFDoc::addLayerNode | ( |  | parentLayerId,
|  |  | {index, name, hasLayer=false} = `{}`
| ) |  |
| inline

Add a new layer node as a child for the specified layer node.

Parameters

  parentLayerId | string - The destination layer node id. It should not be an empty string. Please refer to getLayerNodesJson.
  options | object - New layer node options.
  options.index | number - Child index for the new child layer node. Valid range: from 0 to the number of children of the parent layer node.
  options.name | string - Name for the new layer node. It should not be an empty string.
  options.hasLayer | boolean - True means the new child layer node would be associated with a layer, and false otherwise.

Returns
  Promise<ILayerNode> - A layer node object.

Example:
  async function example (pdfDoc) {
  const layerNodes = await pdfDoc.getLayerNodesJson();
  await pdfDoc.addLayerNode(layerNodes.id,{index:0,name:"newLayer",hasLayer:true});
  }

Since
  10.0.0

## ◆ addPagingSealSignature()

PDFDoc::addPagingSealSignature | ( |  | info | ) |
| inline

Add a paging seal signature field into specified pages.

Parameters

  info | Object - Specifies params information.
  info.pagingSigConfig | Object - Specifies paging seal signature information.
  info.pagingSigConfig.width | number - Specifies paging seal signature width.
  info.pagingSigConfig.height | number - Specifies paging seal signature height.
  info.pagingSigConfig.position | string - Specifies paging seal signature position. One of 'left', 'top', 'right', 'bottom'.
  info.pagingSigConfig.offset | number - Specifies paging seal signature offset. Should not be a negative number.
  info.pagingSigConfig.pageRange | Array - Specifies paging seal signature page index range, like: [startIndex: number, endIndex: number].
  info.pagingSigConfig.firstPagePercent | number - Specifies paging seal signature percent on first page. Should be larger than 0.0, less than 1.0.
  info.pagingSigConfig.image | string - Specifies paging seal signature image, e.g. BLOB URL, HTTP, HTTPS, and Base64URL.

Returns
  Promise<number> - Paging seal signature object number.

Since
  9.1.0
  async function example(pdfViewer) {
  let pdfDoc = pdfViewer.getCurrentPDFDoc();
  let pagingSigConfig = {
  width: 100,
  height: 100,
  position: 'bottom',
  offset: 0,
  pageRange: [1, 6],
  firstPagePercent: 0.5,
  image: 'data:image/png;base64,iVBORw0...',
  };
  let pagingSigObjNum = await pdfDoc.addPagingSealSignature({ pagingSigConfig });
  }

## ◆ addWatermark()

PDFDoc::addWatermark | ( |  | data | ) |
| inline

Add watermark.

Parameters

  watermarkConfig | object - Document watermarking configuration. Example: { type:"text", text:"This is a watermark", pageStart: 0, pageEnd: 1, watermarkSettings:{ position:"TopLeft", offsetX:0, offsetY:0, scale:1, rotation:45, opacity:100 }, watermarkTextProperties:{ font:2, fontSize:20, color:0x000000, fontStyle:"normal" } };
  watermarkConfig.pageStart | number - The start page index. Valid range: from 0 to (this.getPageCount() - 1).
  watermarkConfig.pageEnd | number - The end page index. Valid range: from 0 to (this.getPageCount() - 1).
  watermarkConfig.type | 'text'|'bitmap' - The type of watermark. 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.absScale=100] | number - Absolute scale, only for bitmap, and it will work while the parameter "watermarkConfig.useRelativeScale" is false. Valid range: from 0 to 100. The default value is 100.
  [watermarkConfig.useRelativeScale=true] | boolean - Determine if the scale is relative to the target page. If it is true, use the "watermarkConfig.watermarkSettings.scale", otherwise, use the "watermarkConfig.watermarkTextProperties.fontSize". The default value is true. It cannot be set with "watermarkConfig.isMultiline" at the same time.
  [watermarkConfig.isMultiline=false] | boolean - Whether multiline watermark tiling is supported. It cannot be set with "watermarkConfig.useRelativeScale" at the same time. If the 'type' is bitmap, the larger image requires compression, which may cause distortion
  [watermarkConfig.rowSpace=0] | number - The row spacing for multiple lines of watermark. In points. The default value is 0. It will work while the parameter "watermarkConfig.isMultiline" is true.
  [watermarkConfig.columnSpace=0] | number - The column spacing for multiple lines of watermark. In points. The default value is 0. It will work while the parameter "watermarkConfig.isMultiline" is true.
  watermarkConfig.watermarkSettings | object - Watermark-related configuration.
  [watermarkConfig.watermarkSettings.position=Position.center] | Position - Please Refer to Position. Default: Position.center.
  [watermarkConfig.watermarkSettings.offsetX=0] | number - Horizontal offset. In points. The default value is 0. It will not work while the parameter "watermarkConfig.isMultiline" is true.
  [watermarkConfig.watermarkSettings.offsetY=0] | number - Vertical offset. In points. The default value is 0. It will not work while the parameter "watermarkConfig.isMultiline" is true.
  watermarkConfig.watermarkSettings.flags | Watermark_Flag - Watermark flags. Please refer to Watermark_Flag.
  [watermarkConfig.watermarkSettings.scale=1] | number - Scale coefficient. The default value is 1. It should be greater than 0.01f, Valid range: from 0.01 to 1.
  [watermarkConfig.watermarkSettings.rotation=45] | number - Rotation angle in degrees. The default value is 45.
  [watermarkConfig.watermarkSettings.opacity=100] | 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=Standard_Font.courier] | Standard_Font|number - Specify Font object used for the text. Please refer to Standard_Font.Default: Standard_Font.courier.
  [watermarkConfig.watermarkTextProperties.fontSize=20] | number - Font size.The default value is 20.
  [watermarkConfig.watermarkTextProperties.color=0x000000] | number - Font color<Hexadecimal>. The default value is "0x000000".
  [watermarkConfig.watermarkTextProperties.fontStyle='normal'] | 'normal'|'underline' - The default value is "normal". 1."normal":Watermark font style: normal. 2."underline":Watermark font style: with underline.

Since
  9.0.0

## ◆ applyRedaction()

PDFDoc::applyRedaction | ( |  | ) |
| inline

Apply redaction in marked areas: remove the text or graphics under marked areas permanently. [Support in Server]

Returns
  Promise<false|Array<Array<Annot>>> - FALSE means failure, Array means success. The removed annotation objects in each page.

## ◆ autoRecognitionForm()

PDFDoc::autoRecognitionForm | ( |  | options = `{}` | ) |
| inline

Auto recognition form for PDF documents.

Parameters

  options | Object - Specifies params information.
  options.isSetTooltip | boolean - Specifies whether to set tooltip for form fields. The default is true.

Returns
  Promise<number> - A number for failed or success, 0: not found， 1: success

examples:
  async function example (pdfDoc) {
  let result = await pdfDoc.autoRecognitionForm({isSetTooltip: true});
  return result;
  }

Since
  11.0.0

## ◆ checkPassword()

PDFDoc::checkPassword | ( |  | password | ) |
| inline

Check the type of a specified password.

This function can be used to check the type of any password string, including the password string used for loading document content.
For some PDF document, it have user password and owner password at the same time and these two passwords are same. But current function can only return one type for such password.

Parameters

  password | string - A password string to be detected.

Returns
  Promise<number> - Password type. 0 means invalid password, 1 means no password, 2 means user password, 3 means owner password.

Since
  9.2.0

## ◆ drmEncrypt()

PDFDoc::drmEncrypt | ( |  | drmOptions | ) |
| inline

This class represents a Foxit DRM(Digital Right Management) security handler, used for Foxit DRM encryption.

Parameters

  drmOptions | object -
  [drmOptions.isEncryptMetadata=false] | boolean - A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata, and false means not to encrypt metadata.
  drmOptions.subFilter | string - The sub filter of PDF document.
  drmOptions.cipher | number - Cipher type. Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type::cipherNone.
  drmOptions.keyLength | number - The key length, in bytes. For Cipher_Type::cipherRC4 cipher, this value should be between 5 and 16. For Cipher_Type::cipherAES cipher, this value should be 16 or 32.
  drmOptions.isOwner | boolean - A boolean value to decide whether current user is owner or not. true means current user is owner, and false means current user is not owner. Default: false.
  drmOptions.userPermissions | number - The user permissions. Please refer to values starting from User_Permissions::print and this can be one or combination of these values.
  drmOptions.fileId | string - The file identity string.
  drmOptions.initialKey | string - The user specified initial key for encryption.
  [drmOptions.values] | object - Set the DRM value for a specified parameter. A parameter string as the key name. It should not be an empty string. Followings are pre-defined key names: Issuer: issuer name. Creator: creator of this file. FileID: file ID. FlowCode: flow code for application control. Order: order number. User: user name. ServiceURL: service URL for remote server. Vender: vender name.

## ◆ exportAnnotsToFDF()

PDFDoc::exportAnnotsToFDF | ( |  | fileType = `0`,
|  |  | annots = `null`
| ) |  |
| inline

Export annotation data in a document to a file. Not support Screen Image, Link and Sound. [Support in Server]

Parameters

  fileType | number - Specify data file type. File_Type.xfdf or File_Type.fdf. The default is File_Type.fdf.
  [annots] | Annot[] - Specifies particular annots to be exported. If it's null, all annotations will be exported. [Not support in Server]

Returns
  Promise<Blob> - Blob of annotations data.

## ◆ exportAnnotsToJSON()

PDFDoc::exportAnnotsToJSON | ( |  | annotArray | ) |
| inline

Export the document's annotation data to Json. Not support Screen Image, Link and Sound. [Support in Server]

Parameters

  annots | Array<Annot> - An array with annots that will be exported. All annots will be exported with "null" parameters.

Returns
  Promise<IAnnotationSummary[]> - Json format. please refer to Annot::exportToJson

## ◆ exportFormToFile()

PDFDoc::exportFormToFile | ( |  | fileType = `FileFormat.fdf` | ) |
| inline

Export document form data to file.

Parameters

  fileType | FileFormat -

Returns
  Promise<Blob> - Blob of form data.

## ◆ exportXFAToFile()

PDFDoc::exportXFAToFile | ( |  | fileType = `FileFormat.xdp` | ) |
| inline

Export document form data to file.

Parameters

  fileType | FileFormat - xml, xdp

Returns
  Promise<Blob> - Blob of form data.

Since
  11.0.0

## ◆ extractPages()

PDFDoc::extractPages | ( |  | pageRange | ) |
| inline

Export the given page(s) from the current document.

Parameters

  pageRange | number[][]- A two-dimensional array of page indices(starts from 0) which woulb be extracted. Only positive integer in valid page range is available. For example, [[0],[2,4],[5,7]] means page 0, page 2 to page 3, and page 5 to page6 will be extracted.

Returns
  Promise<ArrayBuffer[]> - Array buffer of PDF document.

## ◆ flatten()

PDFDoc::flatten | ( |  | option | ) |
| inline

Flatten all annotations and interactive form fields in a PDF.

Parameters

  option | number - Specify which objects will be flattened. Please Refer to Flatten_Option

Returns
  Promise<boolean[]> - success flag.

## ◆ getAdditionalAction()

PDFDoc::getAdditionalAction | ( |  | ) |
| inline

Retrives the additional action object.

Returns
  AdditionalAction<DocActionTriggerEvents> - The additional action object used to manipulate additional actions.

Since
  11.0.0

## ◆ getAllBoxesByPageIndex()

PDFDoc::getAllBoxesByPageIndex | ( |  | index | ) |
| inline

Gets all boxes by specified page index.

Parameters

  index | number - Page index of current PDF document.

Returns

       Promise<{
          mediaBox: PDFRect, // Media Box for page boundary
          cropBox: PDFRect, // Crop Box for page boundary
          trimBox: PDFRect, // Trim Box for page boundary
          artBox: PDFRect, // Art Box for page boundary
          bleedBox: PDFRect, // Bleed Box for page boundary
          calcBox: PDFRect, // Content area of PDF page
          minWidth: number, // Minimum media box width of all pages
          minHeight: number, // Minimum media box height of all pages
          width: number, // Media box height of current page
          height: number // Media box height of current page
      }>

Since
  8.4.0

See also
  PDFPage.getAllBoxes

## ◆ getAllPagingSealSignatures()

PDFDoc::getAllPagingSealSignatures | ( |  | pagingSigObjNum | ) |
| inline

Get all paging seal signature object numbers.

Parameters

  [pagingSigObjNum] | number - Paging seal signature object number. If existed will return paging seal signature object numbers array associated with current signature, otherwise return all paging seal signature object numbers in current document.

Returns
  Promise<Array<number>> - All paging seal signature object numbers.

Since
  9.1.0
  async function example(pdfViewer) {
  let pdfDoc = pdfViewer.getCurrentPDFDoc();
  let pdfForm = pdfDoc.getPDFForm();
  let field = pdfForm.getField('Signature0');
  let pagingSigObjNum = field.getWidget(0).getId();
  let allPagingSigObjNums = await pdfDoc.getAllPagingSealSignatures(pagingSigObjNum);
  }

## ◆ getAnnots()

async PDFDoc::getAnnots | ( |  | ) |
| inline

Get an array of all annotations of the current document. [Support in Server]

Returns
  Promise<Annot[]> - The return array contains a collection of 2D arrays, like [[annot1,annot2], [annot3,annot4]...]. The first 2D array matrix corresponds to annotation data in the first page you queried and the second array cell data in the second page, and so on .

## ◆ getComparisonFilterCountSummary()

PDFDoc::getComparisonFilterCountSummary | ( |  | ) |
| inline

Get the count information for each item of the comparison result; The statistical result is the total number of document difference types, but each difference occurs in pairs, so the number of differences is 1 / 2 of the total.

Note
  This feature is only included in the full package

Returns
  {Images: number, Formatting: number, Text: number, Annotation: number} -

Since
  8.5.0

See also
  PDFViewer.compareDocuments

## ◆ getEmbeddedFile()

PDFDoc::getEmbeddedFile | ( |  | key | ) |
| inline

Get the embedded file by the specified key name.

Parameters

  key | string - The key name of the embedded file.

Returns
  Promise<{name: string, data: Blob, description: string, creationDate: number, modificationDate: number}> - The attachment (as file specification object) of a specified key. details as below:
  - name: The file name of the embedded file.
  - data: The data of the embedded file.
  - description: The description of the embedded file.
  - creationDate: The creation date of the embedded file.
  - modificationDate: The modification date of the embedded file.

Since
  9.1.0

## ◆ getEmbeddedFileNames()

PDFDoc::getEmbeddedFileNames | ( |  | ) |
| inline

Get the embedded file list.

Note: It will return the key names of the embedded files. not the file names of the embedded files. Maybe the key name is the same as the file name.

async function example(pdfDoc) {
const res = await pdfDoc.getEmbeddedFileNames();
}

Since
  8.5.0

Returns
  string[] - return the key names of the embedded files

## ◆ getFile()

Promise< File > PDFDoc::getFile | ( |  | options = `{ flags: 0, fileName: this.getFileName(), progressHandler: noop }` | ) |
| inline

Export the PDF document object to the File object.

Parameters

  options | object -
  options.flags | number - Document saving flags. Please refer to Saving_Flag. Default: Saving_Flag::normal.
  options.fileName | string - PDF file name
  option.progressHandler | ExportFileProgress - Progress callback function.

Returns
  Promise<File> - PDF file object

See also
  https://developer.mozilla.org/en-US/docs/Web/API/File
  Additional_Permission
  PDFViewer.constructor customs.getAdditionalPerm

Since
  8.1.0

Example:
  function example(pdfDoc) {
  pdfDoc.getFile({
  flags: 0,
  fileName: 'test.pdf',
  progressHandler:({current,total,status})=>{
  console.log({current,total,status})
  }
  })
  }

## ◆ getFontsInfo()

PDFDoc::getFontsInfo | ( |  | ) |
| inline

Get fonts info.

Returns
  Promise<Array<Record<string, any>>> - Fonts info.
  [{
  "isEmbedded": false,
  "isBold": false,
  "isItalic": false,
  "baseFontName": "SimSun",
  "fontType": {},
  "name": "NotoSansMonoCJKsc-Regular",
  "familyName": "Noto Sans Mono CJK SC Regular",
  "index": 6,
  "docId": "**"
  },]

## ◆ getHeaderFooter()

PDFDoc::getHeaderFooter | ( |  | ) |
| inline

Get HeaderFooter of document.

Note
  It should call PDFDOC::updateHeaderFooter to modify HeaderFooter.

Since
  7.2.0

Returns
  Promise<HeaderFooter> - If no header or footer presents, a null return.

## ◆ getId()

PDFDoc::getId | ( |  | ) |
| inline

Gets the id of the PDF document [Support in Server]

Returns
  string - Document id

## ◆ getInfo()

PDFDoc::getInfo | ( |  | ) |
| inline

Get the information dictionary of the pdf document.

Since
  7.6.0

Returns
  Promise<PDFDictionary> - The information dictionary.

Example:
  async function example (pdfDoc) {
  let infoDict = await pdfDoc.getInfo();
  return infoDict;
  }

## ◆ getLayerNodesJson()

PDFDoc::getLayerNodesJson | ( |  | force = `false` | ) |
| inline

Get the document's layer nodes.

/**

Returns
  Promise<ILayerNode> - Document's layerNodes to JSON.

## ◆ getMetadata()

PDFDoc::getMetadata | ( |  | ) |
| inline

Get metadata of PDF document. [Support in Server]

Returns
  Promise<object> -
  {
  "Title":"",
  "Author":"",
  "Subject":"",
  "Keywords":"",
  "Creator":"",
  "Producer":"",
  "Trapped":"",
  "CreationDate":"",
  "ModDate":"",
  "pdfaid":"",
  };

## ◆ getOpenAction()

PDFDoc::getOpenAction | ( |  | ) |
| inline

Gets the hierarchical structure data of the document's open action.

Returns
  ActionHierarchy - An hierarchical structure data of the action.

Since
  11.0.0

Example:
  function example(pdfDoc) {
  let openAction = pdfDoc.getOpenAction();
  }

## ◆ getPageAnnots()

PDFDoc::getPageAnnots | ( |  | index | ) |
| inline

Get all annotations in a specified page by page index. [Support in Server]

Parameters

  index | number - page index

Returns
  Promise<Annot[]> - Annotation objects.

## ◆ getPageByIndex()

PDFDoc::getPageByIndex | ( |  | index | ) |
| inline

Get the document page [Support in Server]

Parameters

  index | number - Access 0 to this.getPageCount() - 1

Returns
  Promise<PDFPage> - PDFPage

## ◆ getPageCount()

PDFDoc::getPageCount | ( |  | ) |
| inline

Gets the number of document pages [Support in Server]

Returns
  number - Pages count.

## ◆ getPageLabels()

PDFDoc::getPageLabels | ( |  | pageIndexes | ) |
| inline

Get the page labels of the pdf document.

Since
  7.6.0

Parameters

  pageIndexes | number[] - Could be undefined or page number indexes array. If it's undefined, then all the page labels are returned.

Returns
  Promise<string[]> - The page labels array.

examples:
  async function example (pdfDoc) {
  let allPagelabels = await pdfDoc.getPageLabels();
  return allPagelabels;
  }

## ◆ getPasswordType()

PDFDoc::getPasswordType | ( |  | ) |
| inline

Get the type of current used password. [Support in Server]

Returns
  Promise<number> - 0 means invalid password, 1 means no password, 2 means user password, 3 means owner password.

## ◆ getPDFForm()

PDFDoc::getPDFForm | ( |  | ) |
| inline

Get form object of PDF Document. [Support in Server]

Returns
  PDFForm -

## ◆ getPermissions()

PDFDoc::getPermissions | ( |  | ) |
| inline

Get user access permissions. [Support in Server]
If it is the owner of the document, then 4294967292 is put back to indicate full permissions.
.

Returns
  number - User access permission.

Since
  7.1.0

## ◆ getStream()

PDFDoc::getStream | ( |  | writeChunk,
|  |  | flag = `0`,
|  |  | endAllOperations
| ) |  |
| inline

Gets a PDF file stream that can be used to download documents [Support in Server]

Parameters

  writeChunk | (options:{arrayBuffer:ArrayBuffer,offset:number,size:number})=>void - Callbacks in the form of fragment flows: function ({arrayBuffer, offset, size}) {} - arrayBuffer: fragment stream, offset: fragment offset, size: fragment size
  flag | number - Document saving flags. Please refer to Saving_Flag. Default: Saving_Flag::normal.

Returns
  Promise<number> - The total size of the stream

Example:
  function example (pdfDoc) {
  let bufferArray = [];
  return pdfDoc.getStream(function ({arrayBuffer, offset, size}) {
  bufferArray.push(arrayBuffer);
  }).then(function (size) {
  console.log('The total size of the stream', size)
  return new Blob(bufferArray, {type: 'application/pdf'});
  })
  }

See also
  getFile

## ◆ getText()

PDFDoc::getText | ( |  | pages | ) |
| inline

Gets the text content of the specific pages. The type of XFA Documents is not supported.

Parameters

  pages | number[][] - The page index where content will be extracted.

Returns
  TaskProgress<TaskProgressData> -
  function example(pdfDoc) {
  const pageRange = PDFViewCtrl.shared.getRanges([0,2],4)
  const progress = pdfDoc.getText(pageRange);
  const removeOnProgressListener = progress.onProgress(data => {
  console.log(data); // {percent, content} percent - The percentage of progress; content - The text content of pages
  });
  setTimeout(() => {
  removeOnProgressListener();
  progress.cancel(); // cancelled after 1 second
  }, 1000)
  }

Since
  8.2.0

## ◆ getTextSearch()

PDFDoc::getTextSearch | ( |  | pattern,
|  |  | flags
| ) |  |
| inline

Get text search object. [Support in Server]

Parameters

  pattern | string - Specifies text to search.
  flags | number - The following bit of flags can be used individually or in combination. 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
  DocTextSearch -

Example:
  function example (pdfDoc) {
  var textSearch = pdfDoc.getTextSearch('Foxit', 1 | 2);
  textSearch.findNext().then(function (match) {
  if (match) {
  console.log(match);
  console.log(match.getSentence());
  }
  })
  }

## ◆ getUserPermissions()

PDFDoc::getUserPermissions | ( |  | ) |
| inline

Get user access permissions. [Support in Server]

Returns
  number - User access permission. Please refer to values starting from User_Permissions.print and this would be one of these values.

## ◆ getViewPreference()

PDFDoc::getViewPreference | ( |  | ) |
| inline

Get the view preference of the document.

Returns
  Promise<PDFViewPreference> - The View preference.

Since
  11.0.0

Example
  async function example(pdfDoc) {
  let viewPreference = await pdfDoc.getViewPreference();
  }

## ◆ getWordCount()

PDFDoc::getWordCount | ( |  | ) |
| inline

Get the document's word count.

Returns
  Promise<number> - The document's word count.

Since
  10.0.0

## ◆ has3DAnnots()

PDFDoc::has3DAnnots | ( |  | ) |
| inline

Whether the document has 3D annotation.

Returns
  Promise<boolean> - true if the document has 3D annotation, otherwise false.

Since
  10.0.0

## ◆ hasForm()

PDFDoc::hasForm | ( |  | ) |
| inline

Call this function to determine whether the document contains pdf form.

Returns
  Promise<boolean> - true means the document contains form, false otherwise

Since
  7.5.0

## ◆ hasOwnerPassword()

PDFDoc::hasOwnerPassword | ( |  | ) |
| inline

Judge whether the owner password exists.

Returns
  boolean - true means the document has owner password, while false means not.

Since
  9.2.0

## ◆ importAnnotsFromFDF()

PDFDoc::importAnnotsFromFDF | ( |  | fdf,
|  |  | escape = `true`
| ) |  |
| inline

Import data from an FDF file specified by array buffer. [Support in Server]

Parameters

  fdf | File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream.
  [escape=true] | boolean - Skip annotationImportedEx event

Returns
  Promise<void> -

## ◆ importAnnotsFromJSON()

PDFDoc::importAnnotsFromJSON | ( |  | annotsJson | ) |
| inline

Import data from Json. [Support in Server]

Parameters

  annotsJson | IAnnotationSummary[] - Specify annots' json array.

See also
  PDFViewCtrl::pdf::Annot::exportToJson()

Returns
  Promise<void> -

## ◆ importFormFromFile()

async PDFDoc::importFormFromFile | ( |  | file,
|  |  | format,
|  |  | encoding = `'UTF-8'`
| ) |  |
| inline

Import form data from an FDF file specified by array buffer.

Parameters

  file | File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream.
  format | FileFormat - File format, .
  [encoding] | string - File encoding.

Returns
  Promise<void> -
  pdfDoc.importFormFromFile(file,FileFormat.csv,'GBK')

## ◆ importXFAFromFile()

PDFDoc::importXFAFromFile | ( |  | file,
|  |  | format = `FileFormat.xdp`
| ) |  |
| inline

Export document form data to file.

Parameters

  file | File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream. // todo?
  format | FileFormat - xml, xdp

Returns
  Promise<boolean> -

Since
  11.0.0

## ◆ insertBlankPages()

PDFDoc::insertBlankPages | ( |  | pageRange,
|  |  | width,
|  |  | height
| ) |  |
| inline

Insert a new blank PDF page to the specified pages, by indexes.

Parameters

  pageRange | number[][] - A two-dimensional array of page indices(starts from 0) which would be inserted. Only positive integer in valid page range is available. For example, [[0],[2,4],[5,7]] means page 0, page 2 to page 3, and page 5 to page6 will be inserted.
  width | number - Width of new page.
  height | number - Height of new page.

Returns
  Promise<PDFPage[]> - The new PDFPage objects which represents these blank pages.

Example:
  async function example (pdfDoc) {
  const page1 = await pdfDoc.getPageByIndex(0);
  const width = await page1.getWidth();
  const height = await page1.getHeight();
  let result = await pdfDoc.insertBlankPages([[1],[2,4]],width,height);
  return result;
  }

Since
  7.6.0

## ◆ insertPage()

PDFDoc::insertPage | ( |  | pageIndex,
|  |  | width,
|  |  | height
| ) |  |
| inline

Insert a new blank PDF page to document, by index. [Support in Server]

Parameters

  pageIndex | number - The page index for new page.
  width | number - Width of new page.
  height | number - Height of new page.

Returns
  Promise<PDFPage> - A new PDFPage object which represents a blank page.

## ◆ insertPages()

PDFDoc::insertPages | ( |  | {destIndex, file, password="", flags=0, layerName="", startIndex, endIndex} | ) |
| inline

Start to import pages from another PDF document.

Parameters

  insertOptions | object - Options for inserting pages.
  insertOptions.destIndex | number - A page index in current PDF document. Default value:0. If less than 0 or more than total page, will throw error.
  insertOptions.file | File|Blob|ArrayBuffer|TypedArray|DataView - Specify PDF file's stream where pages will be exported from.
  [insertOptions.password=''] | string - Specify document's password. It can be left empty.
  [insertOptions.flags=0] | number - Options for importing pages.0:Import pages normally.1:Import pages with layers. Default value:0.
  [insertOptions.layerName=''] | string - The name of non-selectable label or the prefix name of the non-selectable label to be shown in layer panel of application.If parameter flags is 1, this should not be empty and should be a valid string. If parameter flags is not 1, this string will be ignored.
  insertOptions.startIndex | number - The start index of a range segment. Default value:0. Support negative number, but if total page is 11, the -12 will throw error.
  insertOptions.endIndex | number - The end index of a range segment. Default value:0. Support negative number, but if total page is 11, the -12 will throw error.

Returns
  Promise<PDFPage[]> - Page information array.

## ◆ isCompareDoc()

PDFDoc::isCompareDoc | ( |  | ) |
| inline

Used to determine whether the PDF document is a comparison result document.

Note
  This feature is only included in the full package

Returns
  boolean -

Since
  8.5.0

See also
  PDFViewer.compareDocuments

## ◆ isDocModified()

PDFDoc::isDocModified | ( |  | ) |
| inline

Call this function to determine whether the document is modified if modified return true, false otherwise. [Support in Server]

Returns
  boolean -

Since
  7.2.0

## ◆ isLinearized()

PDFDoc::isLinearized | ( |  | ) |
| inline

Call this function to determine whether the document is represented in linearized (fast web view) format.

Returns
  Promise<boolean> - true means linearized, false otherwise

Since
  7.2.0

## ◆ loadThumbnail()

PDFDoc::loadThumbnail | ( |  | options | ) |
| inline

Loads a thumbnail for a particular page number.

Parameters

  options | object - An object specifying the options for load thumbnails. The following parameters should be properties on this object. The only non-optional parameter is pageNumber
  options.pageIndex | number - The page number of requested thumbnail.
  [options.scale] | number - The scale value to render the page at.
  [options.rotation] | number - The rotation of the page. Valid values are: 0, 90, 180, 270
  [options.type='canvas'] | 'canvas'|'image'|'buffer' - The type of returning result.
  [options.width] | number - Used to calculate the scale if scale value is not provided. If it's passed the scale will be set so the document fits this width. If both width and height are passed the scale value will be set so the document fits the box delimited by them.
  [options.height] | number - Used to calculate the scale if scale value is not provided. If it's passed the scale will be set so the document fits this height. If both width and height are passed the scale value will be set so the document fits the box delimited by them

Returns
  Promise<HTMLCanvasElement | HTMLImageElement | ArrayBuffer> - A HTMLCanvasElement or HTMLImageElement or ArrayBuffer, the type depends on the options.type parameter.

## ◆ makeRedactByPages()

PDFDoc::makeRedactByPages | ( |  | pages | ) |
| inline

Mark pages which are to be redacted.

Parameters

  pages | number[] - page index array which pages to be redacted.

Returns
  Promise<Array<Annot>>

## ◆ mergePDFDoc()

PDFDoc::mergePDFDoc | ( |  | options | ) |
| inline

Merge pages from another PDF document.

Parameters

  options | object - Options object for merging PDF document.
  options.doc | PDFDoc - A PDFDoc object which is the source PDF document. Pages in this document will be imported to current PDF document. Please keep this source PDF document object valid until current document will not be saved any more or is closed
  [options.insertIndex] | number - A page index in current PDF document, This is used to specify where the imported pages will be inserted: If insertIndex is less than or equals to 0, the imported pages will be inserted to the first. If insertIndex is undefined or equals to or greater than current page count, the imported pages will be inserted to the end.
  [options.pages] | number[] - A page index array to specify which pages to be inserted. If this pages array is undefined or empty, all page in the source document will be imported.
  [options.layerName=''] | string - The name of non-selectable label or the prefix name of the non-selectable label to be shown in layer panel of application. Default value: an empty string If this string is empty, the layers will not be imported. If all the pages of source PDF document is to be imported to current document, all layers from source document will be grouped under a non-selectable label, and this string will be directly used as the label. If only part of pages of source PDF document is to be imported to current document, layers in the same page will be grouped under a single non-selectable label, and this string will be used as the prefix name of the label. The label will be like "layerName_Page_X".

Returns
  Promise<void>

See also
  PDFViewer.loadPDFDocByFile
  PDFViewer.loadPDFDocByHttpRangeRequest

Since
  8.3.0

## ◆ movePagesTo()

PDFDoc::movePagesTo | ( |  | pageRange,
|  |  | destIndex = `0`
| ) |  |
| inline

Move the specified pages to a new index position.

Parameters

  pageRange | number[][] - A two-dimensional array of page indices(starts from 0) which would be moved. Only positive integer in valid page range is available. For example, [[0],[2,4],[5,7]] means page 0, page 2 to page 4, and page 5 to page7 will be moved.
  destIndex | number - A page index in current PDF document. Default value:0. If less than 0 or more than total page, will throw error.

Returns
  Promise<string[]> - page id list

Example:
  async function example (pdfDoc) {
  let result = await pdfDoc.movePagesTo([[0],[2,4]],1);
  return result;
  }

Since
  7.6.0

## ◆ movePageTo()

PDFDoc::movePageTo | ( |  | pageIndex,
|  |  | destIndex
| ) |  |
| inline

Move a specified page to a new index position. [Support in Server]

Parameters

  pageIndex | number - Index of the specified page.
  destIndex | number - Index of the destination position.

Returns
  Promise<boolean> - TRUE means success, while FASLE means failure.

## ◆ removeAllEmbeddedFiles()

PDFDoc::removeAllEmbeddedFiles | ( |  | ) |
| inline

Remove all files embedded in the current PDF document.

function example(pdfDoc) {
pdfDoc.removeAllEmbeddedFiles();
}

Since
  8.5.0

Returns
  Promise<boolean> - return true if success, otherwise return false.

## ◆ removeAllWatermarks()

PDFDoc::removeAllWatermarks | ( |  | ) |
| inline

Remove all the watermarks in the document.

Returns
  Promise<boolean> - Return true indicating successful remove watermarks.

Since
  9.2.0

## ◆ removeEmbeddedFileByName()

PDFDoc::removeEmbeddedFileByName | ( |  | name | ) |
| inline

Remove the embedded file by the specified key name.

Parameters

  name | string - The key name of the embedded file. function example(pdfDoc, keyName) { pdfDoc.removeEmbeddedFileByName(keyName); }

Since
  8.5.0

Returns
  Promise<boolean> - return true if success, otherwise return false.

## ◆ removeHeaderFooter()

PDFDoc::removeHeaderFooter | ( |  | ) |
| inline

Remove all headers and foonters of document.

Since
  7.2.0

Returns
  Promise<void> -

## ◆ removeHiddenData()

PDFDoc::removeHiddenData | ( |  | types = `[]` | ) |
| inline

Remove hidden data.

Parameters

  types | string[] - Enumeration for rendering content flags. Please refer to RemoveHiddenDataTypes.

Returns
  Promise<void>

Note
  After completing this operation, the document must be saved and reopened; otherwise, unexpected errors may occur.

Example:
  async function example(pdfDoc) {
  const { CommentsAndMarkups } = PDFViewCtrl.PDF.constant.RemoveHiddenDataTypes
  await pdfDoc.removeHiddenData([CommentsAndMarkups]);
  }

Since
  11.0.0

## ◆ removeLayerGraphicObject()

PDFDoc::removeLayerGraphicObject | ( |  | layerNodeId,
|  |  | pageIndex,
|  |  | graphicObjectIndex
| ) |  |
| inline

Remove a graphics object from the layer node.

Parameters

  layerNodeId | string - The layer node id. It should not be an empty string. Please refer to getLayerNodesJson.
  pageIndex | number - The page index.
  graphicObjectIndex | number - The special graphic object index of the special page. Please refer to addGraphicsObject.

Returns
  Promise<boolean> - TRUE means success, while FALSE means failure.

Example:
  async function example (pdfDoc) {
  const layerNodes = await pdfDoc.getLayerNodesJson();
  let result = await pdfDoc.removeLayerGraphicObject(layerNodes.children&&layerNodes.children[0].id,0,0);
  }

Since
  10.0.0

## ◆ removeLayerNode()

PDFDoc::removeLayerNode | ( |  | layerNodeId | ) |
| inline

Remove of a specified layer node.

Parameters

  layerNodeId | {string} - string ID of a layer node. Please refer to getLayerNodesJson.

Returns
  Promise<boolean> - TRUE means success, while FALSE means failure.

Example:
  async function example (pdfDoc) {
  const layerNodes = await pdfDoc.getLayerNodesJson();
  let result = await pdfDoc.removeLayerNode(layerNodes.children&&layerNodes.children[0].id);
  }

Since
  10.0.0

## ◆ removeOpenAction()

PDFDoc::removeOpenAction | ( |  | ) |
| inline

Removes the document's open action. After removal, the document will no longer perform any actions when opened.

Returns
  Promise<boolean> - A promise that resolves to a boolean indicating whether the operation succeeded (true) or failed (false).

Since
  11.0.0

Example:
  async function example(pdfDoc) {
  let res = await pdfDoc.removeOpenAction();
  }

## ◆ removePage()

PDFDoc::removePage | ( |  | pageIndex | ) |
| inline

Remove a PDF page by page index. [Support in Server]

Parameters

  pageIndex | number - Index of the specified page.

Returns
  Promise<boolean> - TRUE means success, while FASLE means failure.

## ◆ removePages()

PDFDoc::removePages | ( |  | pageRange | ) |
| inline

Remove the specified pages by page indexes.

Parameters

  pageRange | string[][] - A two-dimensional array of page indices(starts from 0) which would be removed. Only positive integer in valid page range is available. For example, [[0],[2,4],[5,7]] means page 0, page 2 to page 3, and page 5 to page6 will be removed.

Returns
  Promise<boolean> - TRUE means success, while FALSE means failure.

Example:
  async function example (pdfDoc) {
  let result = await pdfDoc.removePages([[0],[2,4]]);
  return result;
  }

Since
  7.6.0

## ◆ removePagingSealSignature()

PDFDoc::removePagingSealSignature | ( |  | info | ) |
| inline

Remove paging seal signature. All signature associated with paging seal signature will be removed.

Parameters

  info | Object - Specifies params info.
  info.pagingSigObjNum | number - Paging seal signature object number.

Returns
  Promise<void>

Since
  9.1.0
  async function example(pdfViewer) {
  let pdfDoc = pdfViewer.getCurrentPDFDoc();
  let pagingSigObjNums = await pdfDoc.getAllPagingSealSignatures();
  await pdfDoc.removePagingSealSignature({ pagingSigObjNum: pagingSigObjNums[0] });
  }

## ◆ removeSignature()

PDFDoc::removeSignature | ( |  | fieldName | ) |
| inline

Remove signature.

Note
  If is paging seal signature, will remove all the signatures associated with current paging seal signature.

Parameters

  fieldName | string - The name of the signature field.

Returns
  Promise<boolean> - Return true indicating successful remove signature.

Since
  9.1.0

## ◆ rotatePages()

PDFDoc::rotatePages | ( |  | pageRange,
|  |  | rotation
| ) |  |
| inline

Set the specified pages rotation.

Parameters

  pageRange | number[][] - A two-dimensional array of page indices(starts from 0) which would be rotated. Only positive integer in valid page range is available. For example, [[0],[2,4],[5,7]] means page 0, page 2 to page 3, and page 5 to page6 will be rotated.
  rotation | number - Rotation to be set. Please refer to Rotation.

Returns
  Promise<void> -

Example:
  async function example (pdfDoc) {
  await pdfDoc.rotatePages([[0],[2,4]],Rotation.rotation1)
  }

Since
  7.6.0

## ◆ sanitize()

PDFDoc::sanitize | ( |  | ) |
| inline

Sanitize Document removes metadata and other hidden data.

Returns
  Promise<void>

Note
  After completing this operation, the document must be saved and reopened; otherwise, unexpected errors may occur.

Example:
  async function example(pdfDoc) {
  await pdfDoc.sanitize();
  }

Since
  11.0.0

## ◆ searchText()

PDFDoc::searchText | ( |  | pages,
|  |  | words,
|  |  | options = `{}`
| ) |  |
| inline

Search the specified text on the specified page.

Parameters

  pages | number[] - The page index where content will be extracted.
  words | string[] - Specifies texts to search.
  [options] | {wholeWordsOnly?:boolean,caseSensitive?:boolean} - The matching conditions. { wholeWordsOnly: false, //Whole words only caseSensitive: false, //Case sensitive }

Returns
  object -
  {
  0:[ // Page Index.
  {
  rects: [{...}], // [ PDFRect ]
  word: 'test' // Specifies text
  }]
  1:[]
  }
  function example(pdfDoc) {
  pdfDoc.searchText(
  [0,1],
  ['test'],
  {wholeWordsOnly: true,
  caseSensitive: false},
  )
  }

Since
  8.2.1

## ◆ setEmbeddedFile()

PDFDoc::setEmbeddedFile | ( |  | key,
|  |  | fileSpec
| ) |  |
| inline

Set an embedded attachment (as file specification object) for a specified key.

Parameters

  key | string - The key name of the embedded file. It should not be an empty string. This name should have existed in current PDF document.
  fileSpec | object - The file specification object.
  [fileSpec.name] | string - The file name of the embedded file. It should not be an empty string.
  [fileSpec.data] | File|Blob|ArrayBuffer|TypedArray|DataView - The data of the embedded file.
  [fileSpec.description] | string - The description of the embedded file. It should not be an empty string.
  [fileSpec.creationDate] | number - The creation date of the embedded file.
  [fileSpec.modificationDate] | number - The modification date of the embedded file.

Returns
  Promise<boolean> - return true if success, otherwise return false.

Since
  9.1.0

## ◆ setLayerNodeVisible()

PDFDoc::setLayerNodeVisible | ( |  | layerId,
|  |  | visible
| ) |  |
| inline

Set the visibility of a specified layer node.

Parameters

  layerId | string|number - string ID of a layer node.
  visiable | boolean - true means visible, and false means invisible.

Returns
  Promise<boolean> -

## ◆ setMetadataValue()

PDFDoc::setMetadataValue | ( |  | key,
|  |  | value
| ) |  |
| inline

Set metadata value.

Parameters

  key | string - Metadata key string. It should not be an empty string. Currently it can be one of the following keys: "Title", "Author", "Subject", "Keywords", "Creator", "Producer", "Trapped", "CreationDate", "ModDate", "pdfaid". It can also be some other custom information keys if they're supported by the PDF file.
  value | string - An string value of metadata value.

## ◆ setOpenAction()

PDFDoc::setOpenAction | ( |  | actionType,
|  |  | actionData
| ) |  |
| inline

Sets an action that will be executed automatically when the document is opened.

Parameters

  actionType | ActionType - The action type, it should be one of the following values: ActionType.goto ActionType.uri ActionType.javaScript ActionType.resetForm ActionType.hide
  actionData | GotoActionData|URIActionData|JavaScriptActionData|ResetFormActionData|HideActionData - The action data, the type of actionData is determined by the actionType.

Returns
  Promise<boolean> - A boolean value indicating the success or failure.

Since
  11.0.0

Example:
  async function example(pdfDoc) {
  pdfDoc.setOpenAction(PDF.actions.ActionType.goto, {
  destination: {
  pageIndex: 0,
  zoomMode: PDF.actions.ZoomMode.ZoomXYZ,
  zoomFactor: 1,
  left: 0,
  top: 0,
  bottom: 0,
  right: 0
  }
  })
  }

## ◆ setPagesBox()

PDFDoc::setPagesBox | ( |  | { indexes, width, height, offsetX, offsetY, boxes, removeWhiteMargin } = `{}` | ) |
| inline

Set pages box.

Parameters

  options | object - Options object for set page box.
  options.indexes | number[] - Specifies the index of the page whose box needs to be updated.
  [options.width] | number - New page width (in PDF point unit).
  [options.height] | number - New page height (in PDF point unit).
  [options.offsetX=0] | number - x-axis offset of the page content box, Effective only if the 'width' and 'height' are both greater than the page size.
  [options.offsetY=0] | number - y-axis offset of the page content box, Effective only if the 'width' and 'height' are both greater than the page size.
  [options.boxes] | object - Contains different types of page box rectangles (in PDF coordinate system). This will be ignored when 'removeWhiteMargin' is specified as true.
  [options.boxes.cropBox] | PDFRect - New Crop Box for page boundary. The region to which the contents of page are to be clipped (cropped) white displaying or printing.
  [options.boxes.artBox] | PDFRect - New Art Box for page boundary. The intended dimensions of a finished page after trimming.
  [options.boxes.trimBox] | PDFRect - New Trim Box for page boundary. The region to which the contents of page should be clipped while outputting in a production environment.
  [options.boxes.bleedBox] | PDFRect - New Bleed Box for page boundary. The extent of page's meaningful content (including potential white space) as intended by page's creator.
  [options.removeWhiteMargin=false] | boolean - Whether to remove white borders.

Returns
  Promise<void> -

See also
  PDFPage.getPageBox
  DataEvents.pagesBoxChanged
  async function example (pdfDoc) {
  await pdfDoc.setPagesBox({
  indexes:[0,1],
  width:600,
  height:792,
  offsetX: 40,
  offsetY: 40,
  boxes: {
  artBox: {
  "left": 0,
  "bottom": 0,
  "right": 100,
  "top": 100
  },
  cropBox: {
  "left": 0,
  "bottom": 0,
  "right": 100,
  "top": 100
  },
  trimBox: {
  "left": 10,
  "bottom": 110,
  "right": 510,
  "top": 700
  }
  }
  });
  }

Since
  8.4.0

## ◆ setPasswordAndPermission()

PDFDoc::setPasswordAndPermission | ( |  | userPassword,
|  |  | ownerPassword,
|  |  | permission = `0xfffffffc`,
|  |  | cipher = `cipherType.AES256`,
|  |  | isEncryptMetadata = `true`
| ) |  |
| inline

Set document password and permission.

Parameters

  userPassword | string - user password.
  ownerPassword | string - owner password.
  [permission=0xfffffffc] | number - User_Permissions 32bit numbers, Print PDF document with normal mode. (Bit 3 ); Modify PDF contents. (Bit 4);Extract PDF contents. (Bit 5);Operate text annotations and fill in interactive form fields. (Bit 6);Fill PDF form. (Bit 9);Disabilities support. (Bit 10);Assemble PDF document. (Bit 11);Print PDF document with higher qualities. (Bit 12);
  [cipher='aes256'] | 'none'|'rc4'|'aes128'|'aes256' - Cipher type string. Available values: "none", "rc4", "aes128", "aes256"
  [isEncryptMetadata=true] | boolean - true means to encrypt metadata, and false means not to encrypt metadata

Returns
  Promise<boolean> - TRUE means success, while FALSE means failure

## ◆ sign()

PDFDoc::sign | ( |  | signInfo,
|  |  | DigestSignHandler
| ) |  |
| inline

Sign the current document by the specified signature information.

Note
  If the PDF document already has an existing signature field, the name of the field can be provided in signInfo.fieldName. If signInfo.fieldName is absent, the function will add a new signature field to the document.

Parameters

  signInfo | SignDocInfo - Specifies signature info.
  DigestSignHandler | DigestSignHandler - The digest and sign handler.

Returns
  Promise<ArrayBuffer> - An object with file buffer and byte range.

Since
  7.4.0
  pdfdoc.sign({
  filter: 'Adobe.PPKLite',
  subfilter: 'adbe.pkcs7.sha1',
  flag: 0x1f0,
  distinguishName: 'e=foxitsdk@foxitsoftware.cn',
  location: 'bj',
  reason: 'TestBJ',
  signer: 'web sdk11',
  showTime: true,
  signTime: 1699944340030,
  defaultContentsLength:7942,
  image: 'data:image/png;base64,iVBORw0...',
  rotation: 90,
  timeFormat: {
  format:'YYYY-MM-DD HH:mm:ss Z',
  timeZoneOptions: { prefix: 'GMT' }
  },
  },function sign(signInfo,plainContent){
  return Promise.resolve(certifySign(plainContent))
  })

## ◆ updateHeaderFooter()

PDFDoc::updateHeaderFooter | ( |  | headerFooter | ) |
| inline

Modify header or footer of documents. If there is no header or footer, this function will add one.

Since
  7.2.0

Parameters

  headerFooter | HeaderFooter - HeaderFooter object.

Returns
  Promise<void> -

## ◆ updatePagingSealInfo()

PDFDoc::updatePagingSealInfo | ( |  | info | ) |
| inline

Update paging seal signature.

Parameters

  info | Object - Specifies params info.
  info.pagingSigConfig | Object - Specifies paging seal signature info.
  info.pagingSigConfig.offset | number - Specifies paging seal signature offset. Should not be a negative number.[optional]
  info.pagingSigConfig.firstPagePercent | number - Specifies paging seal signature percent on first page. Should be larger than 0.0, less than 1.0.[optional]
  info.pagingSigObjNum | number - Paging seal signature object number.

Returns
  Promise<number> - Paging seal signature object number.

Since
  11.0.0
  async function example(pdfViewer) {
  let pdfDoc = pdfViewer.getCurrentPDFDoc();
  let pagingSigObjNums = await pdfDoc.getAllPagingSealSignatures();
  let pagingSigConfig = {
  offset: 0,
  firstPagePercent: 0.5,
  };
  let pagingSigObjNum = await pdfDoc.updatePagingSealInfo({ pagingSigConfig, pagingSigObjNum: pagingSigObjNums[0] });
  }

## ◆ updatePagingSealSignature()

PDFDoc::updatePagingSealSignature | ( |  | info | ) |
| inline

Update paging seal signature.

Deprecated:
  Replaced by updatePagingSealInfo API.

Parameters

  info | Object - Specifies params info.
  info.pagingSigConfig | Object - Specifies paging seal signature info.
  info.pagingSigConfig.width | number - Specifies paging seal signature width.
  info.pagingSigConfig.height | number - Specifies paging seal signature height.
  info.pagingSigConfig.position | string - Specifies paging seal signature position. One of 'left', 'top', 'right', 'bottom'.
  info.pagingSigConfig.offset | number - Specifies paging seal signature offset. Should not be a negative number.
  info.pagingSigConfig.pageRange | Array - Specifies paging seal signature page index range, like: [startIndex: number, endIndex: number].
  info.pagingSigConfig.firstPagePercent | number - Specifies paging seal signature percent on first page. Should be larger than 0.0, less than 1.0.
  info.pagingSigConfig.image | string - Specifies paging seal signature image, e.g. BLOB URL, HTTP, HTTPS, and Base64URL.
  info.pagingSigObjNum | number - Paging seal signature object number.

Returns
  Promise<number> - Paging seal signature object number.

Since
  9.1.0
  async function example(pdfViewer) {
  let pdfDoc = pdfViewer.getCurrentPDFDoc();
  let pagingSigObjNums = await pdfDoc.getAllPagingSealSignatures();
  let pagingSigConfig = {
  width: 100,
  height: 100,
  position: 'bottom',
  offset: 0,
  pageRange: [1, 6],
  firstPagePercent: 0.5,
  image: 'data:image/png;base64,iVBORw0...',
  };
  let pagingSigObjNum = await pdfDoc.updatePagingSealSignature({ pagingSigConfig, pagingSigObjNum: pagingSigObjNums[0] });
  }

## ◆ verifySignature()

PDFDoc::verifySignature | ( |  | field,
|  |  | VerifyHandler
| ) |  |
| inline

Verify signature's status.

Parameters

  field | PDFSignature - The signature field to be verified.
  VerifyHandler | (signatureField:PDFSignature,plainBuffer:any,signedData:any,hasDataOutOfScope:any)=>Promise<number> - Verify handler which is used to check signature's validity.

Returns
  Signature_State - Signature's status. Please refer to Signature_State.

Since
  7.4.0
  pdfdoc.verifySignature(field,function(signatureField,plainBuffer,signedData,hasDataOutOfScope){
  var digest = calc(plainBuffer);
  return Promise.resolve(certifyVerify(digest,signedData)).then(ret=>{
  ret = +ret;
  if (ret & 0x400) {// valid
  ret = 0x00000004 // verifyValid
  } else {// invalid.
  ret = 0x00000008; // verifyInvalid
  }
  if (hasDataOutOfScope) {// the document is changed
  if (ret & 0x00000004) {// valid
  ret |= 0x08000000; // verifyChangeLegal
  } else {// invalid.
  ret |= 0x10000000; // verifyChangeIllegal
  }
  }
  return ret;
  })
  })

@2025 Foxit Software Incorporated. All rights reserved.