FoxitPDFSDKforWeb  9.0.0
Foxit PDF SDK for Web
PDFDoc Class Reference
Inheritance diagram for PDFDoc:
Disposable

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...
 
 addHeaderFooter (headerFooter)
 Add new header-footer. 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...
 
 createRootBookmark ()
 Create the root bookmark of the document. 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=0)
 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...
 
 getAllBoxesByPageIndex (index)
 Gets all boxes by specified page index. More...
 
 getAnnots ()
 Get an array of all annotations of the current document. [Support in Server] More...
 
 getBookmarksJson ()
 Get the document's bookmarks to JSON format. 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...
 
 getEmbeddedFileNames ()
 Get the embedded file list. More...
 
 getFile ({ flags=0, fileName=this.getFileName() }={ flags:0, fileName:this.getFileName() })
 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 ()
 Get the document's layer nodes. More...
 
 getMetadata ()
 Get metadata of PDF document. [Support in Server] 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...
 
 getPermission ()
 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...
 
 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...
 
 getRootBookmark (forceRefresh=false)
 Get the root bookmark of the document. More...
 
 getStream (writeChunk, flag=0)
 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 ()
 
 hasForm ()
 Call this function to determine whether the document contains pdf form. 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...
 
 importFormFromFile (file, format, encoding='UTF-8')
 Import form data from an FDF file specified by array buffer. 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...
 
 loadPDFForm ()
 Load form data of PDF document. [Support in Server] 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...
 
 removeEmbeddedFileByName (name)
 Remove the embedded file by name. More...
 
 removeHeaderFooter ()
 Remove all headers and foonters of document. More...
 
 removePage (pageIndex)
 Remove a PDF page by page index. [Support in Server] More...
 
 removePages (pageRange)
 Remove the specified pages by page indexes. More...
 
 rotatePages (pageRange, rotation)
 Set the specified pages rotation. More...
 
 searchText (pages, words, options={})
 Search the specified text on the specified page. More...
 
 setLayerNodeVisible (layerId, visible)
 Set the visibility of a specified layer node. More...
 
 setMetadataValue (key, value)
 Set metadata value. 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)
 Get signature file stream without signed data. More...
 
 updateHeaderFooter (headerFooter)
 Modify header or footer of documents. If there is no header or footer, this function will add one. More...
 
 verifySignature (field, VerifyHandler)
 Verify signature's status. More...
 
- Public Member Functions inherited from Disposable
 addDestroyHook (...hooks)
 
 destroy ()
 

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
pageIndexnumber - Specifies target page.
annotJsonobject - 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
pageIndexnumber - Specifies target page.
annotJsonsobject - Annotation's json object.
headerIndexnumber - Indicates the header annotation's index.
Returns
Promise<Annot[]> - Annotations added as a group.
See also
PDFPage::addAnnotGroup

◆ 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
headerfooterHeaderFooter - A valid header-footer object to be added to current document.
Returns
Promise<object> - A null for failed or success.

◆ addWatermark()

PDFDoc::addWatermark (   data)
inline

Add watermark.

Parameters
watermarkConfigobject - 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.pageStartnumber - The start page index. Valid range: from 0 to (this.getPageCount() - 1).
watermarkConfig.pageEndnumber - 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.
[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.watermarkSettingsobject - 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.flagsWatermark_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.

◆ createRootBookmark()

PDFDoc::createRootBookmark ( )
inline

Create the root bookmark of the document.

Returns
Promise<PDFBookmark> - root bookmark.

◆ drmEncrypt()

PDFDoc::drmEncrypt (   drmOptions)
inline

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

Parameters
drmOptionsobject -
[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.subFilterstring - The sub filter of PDF document.
drmOptions.ciphernumber - Cipher type. Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type::cipherNone.
drmOptions.keyLengthnumber - 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.isOwnerboolean - 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.userPermissionsnumber - The user permissions. Please refer to values starting from User_Permissions::print and this can be one or combination of these values.
drmOptions.fileIdstring - The file identity string.
drmOptions.initialKeystring - 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
fileTypenumber - 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
annotsArray<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 = 0)
inline

Export document form data to file.

Parameters
fileTypenumber - Specify data file type. Please refer to File_Type. The default is File_Type.fdf.
Note
For File_Type.csv and File_Type.txt, char encoding is UTF-8.
Returns
Promise<Blob> - Blob of form data.

◆ extractPages()

PDFDoc::extractPages (   pageRange)
inline

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

Parameters
pageRangenumber[][]- 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
optionnumber - Specify which objects will be flattened. Please Refer to Flatten_Option
Returns
Promise<boolean[]> - success flag.

◆ getAllBoxesByPageIndex()

PDFDoc::getAllBoxesByPageIndex (   index)
inline

Gets all boxes by specified page index.

Parameters
indexnumber - 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

◆ getAnnots()

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 .

◆ getBookmarksJson()

PDFDoc::getBookmarksJson ( )
inline

Get the document's bookmarks to JSON format.

Deprecated:
Returns
Promise<Object> - Document's bookmarks to JSON.

◆ 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

◆ getEmbeddedFileNames()

PDFDoc::getEmbeddedFileNames ( )
inline

Get the embedded file list.

async function example(pdfDoc) {
const res = await pdfDoc.getEmbeddedFileNames();
// ['butterfly.pdf', 'test.doc']
}
Since
8.5.0
Returns
string[] - reture embedded file name list

◆ getFile()

Promise< File > PDFDoc::getFile (   options = { flags: 0, fileName: this.getFileName() })
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
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

◆ 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 ( )
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":"",
};

◆ getPageAnnots()

PDFDoc::getPageAnnots (   index)
inline

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

Parameters
indexnumber - page index
Returns
Promise<Annot[]> - Annotation objects.

◆ getPageByIndex()

PDFDoc::getPageByIndex (   index)
inline

Get the document page [Support in Server]

Parameters
indexnumber - 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
pageIndexesnumber[] - 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]

Note
If PDFDoc.loadPDFForm() isn't called first, unexperted error will happen.
Returns
PDFForm -

◆ getPermission()

PDFDoc::getPermission ( )
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.
.

Deprecated:
Use PDFDoc::getPermissions instead
Returns
Promise<number> - User access permission.

◆ 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

◆ getRootBookmark()

PDFDoc::getRootBookmark (   forceRefresh = false)
inline

Get the root bookmark of the document.

Returns
Promise<PDFBookmark> - root bookmark. Null if no one.

◆ getStream()

PDFDoc::getStream (   writeChunk,
  flag = 0 
)
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
flagnumber - 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
pagesnumber[][] - 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
patternstring - Specifies text to search.
flagsnumber - 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 -

◆ 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

◆ importAnnotsFromFDF()

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

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

Parameters
fdfFile|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
annotsJsonIAnnotationSummary[] - Specify annots' json array.
See also
PDFViewCtrl::pdf::Annot::exportToJson()
Returns
Promise<void> -

◆ importFormFromFile()

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

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

Parameters
fileFile|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream.
formatFile_Type - File format. Please refer to File_Type.
[encoding]string - File encoding. Available values are same as second parameter of FileReader.readAsText.
Returns
Promise<void> -
pdfDoc.importFormFromFile(file,File_Format.csv,'GBK')

◆ insertBlankPages()

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

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

Parameters
pageRangenumber[][] - 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.
widthnumber - Width of new page.
heightnumber - 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
pageIndexnumber - The page index for new page.
widthnumber - Width of new page.
heightnumber - 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
insertOptionsobject - Options for inserting pages.
insertOptions.destIndexnumber - A page index in current PDF document. Default value:0. If less than 0 or more than total page, will throw error.
insertOptions.fileFile|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.startIndexnumber - 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.endIndexnumber - 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

◆ loadPDFForm()

PDFDoc::loadPDFForm ( )
inline

Load form data of PDF document. [Support in Server]

Returns
Promise<PDFForm> -

◆ loadThumbnail()

PDFDoc::loadThumbnail (   options)
inline

Loads a thumbnail for a particular page number.

Parameters
optionsobject - 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.pageIndexnumber - 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
pagesnumber[] - page index array which pages to be redacted.
Returns
Promise<Array<Annot>>

◆ mergePDFDoc()

PDFDoc::mergePDFDoc (   options)
inline

Merge pages from another PDF document.

Parameters
optionsobject - Options object for merging PDF document.
options.docPDFDoc - 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
pageRangenumber[][] - 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.
destIndexnumber - 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
pageIndexnumber - Index of the specified page.
destIndexnumber - 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> -

◆ removeEmbeddedFileByName()

PDFDoc::removeEmbeddedFileByName (   name)
inline

Remove the embedded file by name.

Parameters
namestring - the embedded file name
function example(pdfDoc, fileName) {
pdfDoc.removeEmbeddedFileByName(fileName);
}
Since
8.5.0
Returns
Promise<boolean> -

◆ removeHeaderFooter()

PDFDoc::removeHeaderFooter ( )
inline

Remove all headers and foonters of document.

Since
7.2.0
Returns
Promise<void> -

◆ removePage()

PDFDoc::removePage (   pageIndex)
inline

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

Parameters
pageIndexnumber - 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
pageRangestring[][] - 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

◆ rotatePages()

PDFDoc::rotatePages (   pageRange,
  rotation 
)
inline

Set the specified pages rotation.

Parameters
pageRangenumber[][] - 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.
rotationnumber - 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

◆ searchText()

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

Search the specified text on the specified page.

Parameters
pagesnumber[] - The page index where content will be extracted.
wordsstring[] - 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

◆ setLayerNodeVisible()

PDFDoc::setLayerNodeVisible (   layerId,
  visible 
)
inline

Set the visibility of a specified layer node.

Parameters
layerIdstring|number - string ID of a layer node.
visiableboolean - true means visible, and false means invisible.
Returns
Promise<boolean> -

◆ setMetadataValue()

PDFDoc::setMetadataValue (   key,
  value 
)
inline

Set metadata value.

Parameters
keystring - 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.
valuestring - An string value of metadata value.

◆ setPagesBox()

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

Set pages box.

Parameters
optionsobject - Options object for set page box.
options.indexesnumber[] - 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
userPasswordstring - user password.
ownerPasswordstring - 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

Get signature file stream without signed data.

Note
If the current document has an existing signature field, a field name will be passed to the signInfo.fieldName. If the value of signInfo.fieldName is absent, this function will add a new signature field.
Parameters
signInfoobject - Specifies signature info.
signInfo.filterobject - Specifies signature info.
signInfo.subfilterobject - Specifies signature info.
[signInfo.rect]PDFRect - (Required if fieldName is absent)Position of signature.
[signInfo.pageIndex]number - (Required if fieldName is absent) Specify a page index on which this signature will appear.
[signInfo.rotation=0]0|90|180|270 - The rotation angle of the signature form widget. The number of degrees by which the widget annotation is rotated counterclockwise relative to the page.
[signInfo.flag=0x100]number - The appearance flag for signing. Please refer to Signature_Ap_Flags.
[signInfo.signer]string - The signer of the signature.
[signInfo.reason]string - The reason for signing.
[signInfo.email]string - The email of the signing.
[signInfo.image]string - (e.g. BLOB URL, HTTP, HTTPS, and Base64URL)The image for singing.
[signInfo.distinguishName]string - The distinguished name of signing.
[signInfo.location]string - The location of signing.
[signInfo.text]string - The signing descriptive information.
[signInfo.defaultContentsLength]number - 7942 is the default length of signature contents, in bytes. It should not be less than 4098.
[signInfo.fieldName]string - (Required if rect and pageIndex are absent) Specifies which field to be signed.
[signInfo.timeFormat]object - Customize the date format.
[signInfo.timeFormat.format]string - The default is 'YYYY.MM.DD HH:mm:ss Z'.
[signInfo.timeFormat.timeZoneOptions]object - Used if the date format parameter contains 'Z'.
[signInfo.timeFormat.timeZoneOptions.separator]string - The default is '\''.
[signInfo.timeFormat.timeZoneOptions.prefix]string - The default is ''.
[signInfo.timeFormat.timeZoneOptions.showSpace]boolean - The default is 'true'.
DigestSignHandler(signInfo:Record<string,any>,plainContent:Blob)=>Promise<ArrayBuffer> - 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,
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
headerFooterHeaderFooter - HeaderFooter object.
Returns
Promise<void> -

◆ verifySignature()

PDFDoc::verifySignature (   field,
  VerifyHandler 
)
inline

Verify signature's status.

Parameters
fieldPDFField - The signature field to be verified.
VerifyHandler(signatureField:any,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))
})

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