FoxitPDFSDKforWeb  7.1.1
Foxit PDF SDK for Web
PDFDoc Class Reference

Public Member Functions

 addAnnot (pageIndex, annotJson)
 Add an annotation into a specified page. More...
 
 addAnnotGroup (pageIndex, annotJsons, headerIndex)
 Add a group annotation. More...
 
 applyRedaction ()
 Apply redaction in marked areas: remove the text or graphics under marked areas permanently. More...
 
 createRootBookmark ()
 Create the root bookmark of the document. More...
 
 drmEncrypt (options)
 
 exportAnnotsToFDF (fileType=0)
 Export annotation data in a document to a file. More...
 
 exportAnnotsToJSON ()
 Export the document's annotation data to Json. 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...
 
 getAnnots ()
 Get an array of all annotations of the current document. More...
 
 getBookmarksJson ()
 Get the document's bookmarks to JSON format. More...
 
 getId ()
 Gets the id of the PDF document. More...
 
 getLayerNodesJson ()
 Get the document's layer nodes. More...
 
 getMetadata ()
 Get metadata of PDF document. More...
 
 getPageAnnots (index)
 Get all annotations in a specified page by page index. More...
 
 getPageByIndex (index)
 Get the document page. More...
 
 getPageCount ()
 Gets the number of document pages. More...
 
 getPasswordType ()
 Get the type of current used password. More...
 
 getPDFForm ()
 Get form object of PDF Document. More...
 
 getPermission ()
 Get user access permissions.
If it is the owner of the document, then 4294967292 is put back to indicate full permissions.
. More...
 
 getPermissions ()
 Get user access permissions.
If it is the owner of the document, then 4294967292 is put back to indicate full permissions.
. More...
 
 getRootBookmark ()
 Get the root bookmark of the document. More...
 
 getStream (writeChunk)
 Gets a PDF file stream that can be used to download documents. More...
 
 getTextSearch (pattern, flags)
 get doc text search object More...
 
 getUserPermissions ()
 
 importAnnotsFromFDF (fdf)
 Import data from an FDF file specified by array buffer. More...
 
 importAnnotsFromJSON (annotsJson)
 Import data from Json. More...
 
 importFormFromFile (file, isXML=false)
 Import form data from an FDF file specified by array buffer. More...
 
 insertPage (pageIndex, width, height)
 Insert a new blank PDF page to document, by index. More...
 
 insertPages ({destIndex, file, password="", flags=0, layerName="", startIndex, endIndex})
 Start to import pages from another PDF document. More...
 
 loadPDFForm ()
 Load form data of PDF document. More...
 
 makeRedactByPages (pages)
 Mark pages which are to be redacted. More...
 
 movePageTo (pageIndex, destIndex)
 Move a specified page to a new index position. More...
 
 removePage (pageIndex)
 Remove a PDF page by page index. More...
 
 setLayerNodeVisiable (layerId, visiable)
 Set the visibility of a specified layer node. More...
 
 setMetadataValue (key, value)
 Set metadata value. More...
 
 setPasswordAndPermission (userPassword, ownerPassword, permission=0xfffffffc, cipher=cipherType.AES256, isEncryptMetaData=true)
 Set document password and permission. More...
 

Detailed Description

PDF document object

Member Function Documentation

◆ addAnnot()

PDFDoc::addAnnot (   pageIndex,
  annotJson 
)
inline

Add an annotation into a specified page.

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.

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

◆ applyRedaction()

PDFDoc::applyRedaction ( )
inline

Apply redaction in marked areas: remove the text or graphics under marked areas permanently.

Returns
{Promise.<boolean|Annot[][]>} - FASLE 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 (   options)
inline

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

Parameters
options{object}
options.isEncryptMetadata{boolean} A boolean value to decide whether to encrypt metadata or not. true means to encrypt metadata, and false means not to encrypt metadata.
options.subFilter{string} The sub filter of PDF document.
options.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.
options.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.
options.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.
options.userPermissions{number} The user permissions. Please refer to values starting from User_Permissions::print and this can be one or combination of these values.
options.fileId{string} The file identity string.
options.initialKey{string} The user specified initial key for encryption.
[options.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)
inline

Export annotation data in a document to a file.

Parameters
fileType{number} - Specify data file type: 0 for FDF, 1 for XFDF; The default is 0.
Returns
{Promise.<Blob>} - Blob of annotations data.

◆ exportAnnotsToJSON()

PDFDoc::exportAnnotsToJSON ( )
inline

Export the document's annotation data to Json.

Returns
{Promise.<object[]>} - Json format. please refer to #exportToJson

◆ exportFormToFile()

PDFDoc::exportFormToFile (   fileType = 0)
inline

Export document form data to file.

Parameters
fileType{number} - Specify data file type: 0 for FDF, 1 for XFDF, 2 for XML; The default is 0.
Returns
{Promise.<Blob>} - Blob of form data.

◆ extractPages()

PDFDoc::extractPages (   pageRange)
inline

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

Parameters
pageRange{Array} - A two-dimensional array of page numbers to extract.
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
option{number} - Flatten type: e_FlattenAll = 0, e_FlattenNoAnnot = 0x0001, e_FlattenNoFormControl = 0x0002. 0x0000 means flatten all annotations and interactive form. 0x0001 means flatten all interactive form. 0x0002 means flatten all annotations.
Returns
{Promise.<boolean[]>} - success flag.

◆ getAnnots()

PDFDoc::getAnnots ( )
inline

Get an array of all annotations of the current document.

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.

Returns
{Promise.<Object>} - Document's bookmarks to JSON.

◆ getId()

PDFDoc::getId ( )
inline

Gets the id of the PDF document.

Returns
{string} - Document id

◆ getLayerNodesJson()

PDFDoc::getLayerNodesJson ( )
inline

Get the document's layer nodes.

Returns
{Promise.<LayerNode[][]>} - Document's layerNodes to JSON.

◆ getMetadata()

PDFDoc::getMetadata ( )
inline

Get metadata of PDF document.

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.

Parameters
index{number} - page index
Returns
{Promise.<Annot[]>} - Annotation objects.

◆ getPageByIndex()

PDFDoc::getPageByIndex (   index)
inline

Get the document page.

Parameters
index{number} - Access 0 to this.getPageCount() - 1
Returns
{Promise.<PDFPage>} - PDFPage

◆ getPageCount()

PDFDoc::getPageCount ( )
inline

Gets the number of document pages.

Returns
{number} - Pages count.

◆ getPasswordType()

PDFDoc::getPasswordType ( )
inline

Get the type of current used password.

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.

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

◆ getPermission()

PDFDoc::getPermission ( )
inline

Get user access permissions.
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.
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 ( )
inline

Get the root bookmark of the document.

Returns
{Promise.<PDFBookmark>} - root bookmark.

◆ getStream()

PDFDoc::getStream (   writeChunk)
inline

Gets a PDF file stream that can be used to download documents.

Parameters
writeChunk{Function} - Callbacks in the form of fragment flows: function ({arrayBuffer, offset, size}) {} - arrayBuffer: fragment stream, offset: fragment offset, size: fragment size
Returns
{Promise.<{number}>} - The total size of the stream
examples:
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'});
})
}

◆ getTextSearch()

PDFDoc::getTextSearch (   pattern,
  flags 
)
inline

get doc text search object

Parameters
pattern{string} - Specifies word to search.
flags{number} - Refer to the following values, which can be one or a combination of these values.
0: No special searching options.
1: If set, match the case of keyword when searching.
2: If set, match the whole word of keyword when searching.
4: If set, match the key word consecutively when searching. For example, "CC" will be matched twice in "CCC".
Returns
{DocTextSearch}
examples:
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.

Returns
{number}

◆ importAnnotsFromFDF()

PDFDoc::importAnnotsFromFDF (   fdf)
inline

Import data from an FDF file specified by array buffer.

Parameters
fdf{File|Blob|ArrayBuffer|TypeArray|ViewData} - Specify fdf file's stream.
Returns
{Promise.<T>}

◆ importAnnotsFromJSON()

PDFDoc::importAnnotsFromJSON (   annotsJson)
inline

Import data from Json.

Parameters
annotsJson{object[]} - Specify annots' json array.
See also
PDFViewCtrl::pdf::Annot::exportToJson()
Returns
{Promise.<T>}

◆ importFormFromFile()

PDFDoc::importFormFromFile (   file,
  isXML = false 
)
inline

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

Parameters
file{File|Blob|ArrayBuffer|TypeArray|ViewData} - Specify fdf file's stream.
isXML{boolean} - Indicate wheather is a xml file, default is false.
Returns
{Promise.<T>}

◆ insertPage()

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

Insert a new blank PDF page to document, by index.

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
options.destIndex{number} - A page index in current PDF document.
options.file{File|Blob|ArrayBuffer|TypeArray|ViewData} - Specify PDF file's stream where pages will be exported from.
options.password{string} - Specify document's password. It can be left empty.
options.flags{number} - Options for importing pages.0:Import pages normally.1:Import pages with layers.2:Import pages without cloning stream objects into memory.Default value:0.
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.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.
options.startIndex{number} - The start index of a range segment.
options.endIndex{number} - The end index of a range segment.
Returns
{Promise.<Array>} - Page information array.

◆ loadPDFForm()

PDFDoc::loadPDFForm ( )
inline

Load form data of PDF document.

Returns
{Promise.<PDFForm>}

◆ makeRedactByPages()

PDFDoc::makeRedactByPages (   pages)
inline

Mark pages which are to be redacted.

Parameters
pages{Array[number]} - page index array which pages to be redacted.
Returns
{Promise.<Array[Annot]>}

◆ movePageTo()

PDFDoc::movePageTo (   pageIndex,
  destIndex 
)
inline

Move a specified page to a new index position.

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.

◆ removePage()

PDFDoc::removePage (   pageIndex)
inline

Remove a PDF page by page index.

Parameters
pageIndex{number} - Index of the specified page.
Returns
{Promise.<boolean>} - TRUE means success, while FASLE means failure.

◆ setLayerNodeVisiable()

PDFDoc::setLayerNodeVisiable (   layerId,
  visiable 
)
inline

Set the visibility of a specified layer node.

Parameters
layerId{string} - 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.

◆ 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{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{string} - Cipher_Type Cipher type, Available values: "none", "rc4", "aes128", "aes256"
isEncryptMetaData{boolean} - true means to encrypt metadata, and false means not to encrypt metadata
Returns
{Promise.<boolean>} - TRUE means success, while FASLE means failure

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