Methods
-
<static> adjustViewerSize(width, height)
-
Adjusts the Viewer size by setting parameters 'width and height'.
Parameters:
Name Type Description widthNumber Sets the width of the Viewer.
heightNumber Sets the height of the Viewer.
-
<static> canRedo()
-
Check if it can redo
Returns:
- Type
- boolean
-
<static> canUndo()
-
Check if it can undo
Returns:
- Type
- boolean
-
<static> closeFile()
-
Close current PDF file.
Returns:
True if close successful, else return false.
- Type
- Boolean
-
<static> configureContextmenu(type, configuration)
-
Parameters:
Name Type Description typeWebPDF.ContextMenuType configurationObject Properties
Name Type Argument Description mainObject Properties
Name Type Description clsstring attrsobject.<string, string> itemsArray.<IContextMenuItem> popupObject <optional>
Properties
Name Type Description clsstring attrsobject.<string, string> itemsArray.<IContextMenuItem> -
<static> createBlankPDF(pageCount, width, height)
-
Creates a blank document based on the page numbers, width and height.
Parameters:
Name Type Description pageCountNumber The page numbers of the created blank document.
widthNumber The page width of the created blank document.
heightNumber The page height of the created blank document.
-
<static> createPropertyEditorClass(classDeclaration [, baseEditorClass])
-
Parameters:
Name Type Argument Description classDeclarationWebPDF.ClassDefinition baseEditorClassclass <optional>
Returns:
- Type
- class
-
<static> deleteAnnots(annots)
-
Delete the specified anntation based on the given parameter.
Parameters:
Name Type Description annotsArray.<PDFAnnotDelegator> -
<static> enableJSAction(enable)
-
Function defined to enable JavaScript action or not.
Parameters:
Name Type Description enableBoolean JavaScript or not.
-
<static> enableSafeMode(enable)
-
Function defined to enable safe mode or not.
Parameters:
Name Type Description enableBoolean safe mode or not.
-
<static> exportAnnotsToFDF()
-
Export annotations of current document into a FDF file.
This function supports the following annotation types:
highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Current support only comments data and does not include PDF form data.Example
WebPDF.ViewerInstance.exportAnnotsToFDF();
-
<static> exportAnnotsToJson()
-
Export annotations of current document to JSON data.
This function supports the following annotation types: highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Current support only comments data and not include PDF form data.Returns:
a promise that resolves to an object with info for all doucment annotations.
Returns the corresponding field of the value type: "ty", flag: "f", rect: "rc", content: "c", name: "n", borderWidth: "bw", borderStyle: "bs", color: "cl", fillColor:"fcl", dash:"d", highlight: "hl", quadPoints: "Quad", destinationInfo: "ds", openState: "op", modifyDate: "md", state: "st", stateModel: "stm", opacity: "ca", creationDate: "cd", subject: "subj", title: "tit", popup: "pop", replyChain: "rpy", stateList: "stat", action: "act", group: "grp", subType: "subty", textAnnotName: "txtn", ft: "ft", defaultAp: "da", fontSize: "fs", fontColor: "fc", fontName: "ftn", lineHeight: "lnh", fontHeight: "fh", textAlign: "q", it: "it", inkList: "ikl", inkColor: "ikc", inkBorderWidth: "ikw", vts: 'vts', lineRect:"l", lineStyle:"le", rotate: "r", pdf:"pdf", del:"del", icon:"stamp_ic", dynamic:"dyna", dyflag :"df", dyContents :"dc", rectDiffer: "rd", freeCoordinatesLine: "ftcl", //redact overlayCode:"oc", overlayText:"ot", areahi: "areahi",- Type
- Promise
Example
WebPDF.ViewerInstance.exportAnnotsToJson().then(function(arr){console.log(arr)}) console result: [ { "number": 0, "annots": [ { "Quad": [ 57.75, 615.28, 289.5, 615.28, 57.75, 602.82, 289.5, 602.82, 57.75, 602.53, 230.71, 602.53, 57.75, 590.08, 230.71, 590.08 ], "bs": 0, "c": "", "ca": 1, "cd": "1384916293", "cl": "#ffed00", "f": 4, "md": "1384916293", "n": "bdf5db1c-cd19-4421-a70b-e28babf3f047", "pop": { "f": 28, "md": "1384887493", "n": "1e547ca0-407d-489e-9da3-15bc8257520c", "op": 0, "rc": [ 458, 615, 638, 495 ] }, "r": 0, "rc": [ 57.75, 615.28, 289.5, 590.08 ], "subj": "Highlight", "subty": "Highlight", "tit": "foxit", "ty": "Markup" }, { "bs": 0, "c": "Butterflies have been admired for centuries for their physical beauty and behavioural display.", "ca": 1, "cd": "1384916316", "cl": "#ffff00", "f": 28, "md": "1385961736", "n": "c97db9f7-5645-4d06-b5f4-6f9bc91231c2", "pop": { "f": 28, "md": "1384887516", "n": "7f53f835-1c8b-4a2e-80c7-992f9469b58b", "op": 1, "rc": [ 281, 606, 460, 486 ] }, "r": 0, "rc": [ 335.69, 490.19, 355.69, 470.19 ], "subj": "Note", "subty": "Text", "tit": "foxit", "txtn": "Comment", "ty": "Markup" } ] } ] -
<static> exportAnnotsToXFDF()
-
Export annotations of current document into a XFDF file.
This function supports the following annotation types:
highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightareaExample
WebPDF.ViewerInstance.exportAnnotsToXFDF();
-
<static> exportAnnotsToXFDFStream(callback)
-
Export annotations of current document into a XFDF Stream.
This function supports the following annotation types:
highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightareaParameters:
Name Type Description callbackfunction The callback function to receive FDF stream with Uint8Array type.
Example
WebPDF.ViewerInstance.exportAnnotsToXFDFStream(function(uint8Array) { //use uint8Array to do... }); -
<static> exportDocument(fileName [, useCustomWrapperPDF])
-
Export current document to local browsers.
Parameters:
Name Type Argument Default Description fileNameString The name of the file to be exported. If null, use the default file name.
useCustomWrapperPDFboolean <optional>
true -
<static> exportDocumentStream(receiveFunction)
-
Extract document to stream.
Parameters:
Name Type Description receiveFunctionfunction Callback function to store stream after export document.
Example
function getFormXMLBuffer(buffer){ //the variable which store form xml buffer(Uint8Array, and utf8 encoded). } WebPDF.ViewerInstance.exportDocumentStream(getFormXMLBuffer); -
<static> exportInkSigntoJson()
-
Export inksign data of current document to JSON data.
Returns:
a promise that resolves to an object with info for ink signature data.
- Type
- Promise
Example
WebPDF.ViewerInstance.exportInkSigntoJson().then(function(arr){console.log(arr)}) console result: [ { "pageIndex": 0, "inkSignList": [ { "isStraddle": false, "pageIndex": 0, "r": 0, "signer": "signer", "dn": "domain", "reason": "", "location": "", "contact": "contactInfo@email.com", "rc": [ 83.766, 455.25, 128.766, 447.75 ], "hash": 1, "subty": "InkSign", "inkData": { "pencil": [ { "color": 0, "width": 33.75, "points": [ [ 83.766, 455.25 ], [ 90.094125, 455.25 ], [ 102.750375, 455.25 ], [ 109.0785, 455.25 ], [ 121.73475, 455.25 ] ] } ], "rect": [ 379.6875, 278.4375, 430.3125, 278.4375 ], "per": 1, "def": 1, "inkSignId": "1528201919" }, "n": "71a95299-ff5b-4cce-ab17-7681edc46f82" } ] } ] -
<static> fire(type, data)
-
Fires an event with the given name and data.
Parameters:
Name Type Description typeString The type of event to fire.
dataObject An object with properties that should end up on the event object for the given event.
Returns:
The event object.
- Type
- Object
-
<static> flattenPages(includeCallback, pageRange, flags)
-
Flatten document annotations and form fields by specified page numbers.
Parameters:
Name Type Description includeCallbackfunction The callback function to inform the method whether to include current document modifications or not.
That means if the callback return false, the caller need to save the changes firstly, for else, the method will
contain all unsaved changes in final result file.pageRangeString The page ranges to be flatten, like '1,2-3,4-5', -1 means to flatten all pages.
flagsNumber The flatten options.The value can be one or combination of below definition:
FLATTENFLAG_DISPLAY 0
FLATTENFLAG_PRINT 1
FLATTENFLAG_NOANNOT 2
FLATTENFLAG_NOFORMCONTROL 4
combination: 3 = 1 + 2 = FLATTENFLAG_PRINT + FLATTENFLAG_NOANNOTReturns:
A Promise object. If the promise resolve success, it will return an buffer for result file.
Example
WebPDF.ViewerInstance.flattenPages(null,'-1',0).then(function (buffer) { //call opening file API or save buffer to database }); -
<static> focus()
-
Focus the viewport so it can be natively scrolled with the keyboard.
-
<static> getAnnotDetailJson(pageIndex, annotName)
-
- Export annotation of current document to JSON data.
This function supports the following annotation types: highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Note: Currently includes only comments data.Parameters:
Name Type Description pageIndexnumber The specifies page index that starts at zero.
annotNamestring The annotation name.
Returns:
annotation json
Returns the corresponding field of the value type: "ty", flag: "f", rect: "rc", content: "c", name: "n", borderWidth: "bw", borderStyle: "bs", color: "cl", fillColor:"fcl", dash:"d", highlight: "hl", quadPoints: "Quad", destinationInfo: "ds", openState: "op", modifyDate: "md", state: "st", stateModel: "stm", opacity: "ca", creationDate: "cd", subject: "subj", title: "tit", popup: "pop", replyChain: "rpy", stateList: "stat", action: "act", group: "grp", subType: "subty", textAnnotName: "txtn", ft: "ft", defaultAp: "da", fontSize: "fs", fontColor: "fc", fontName: "ftn", lineHeight: "lnh", fontHeight: "fh", textAlign: "q", it: "it", inkList: "ikl", inkColor: "ikc", inkBorderWidth: "ikw", vts: 'vts', lineRect:"l", lineStyle:"le", rotate: "r", pdf:"pdf", del:"del", icon:"stamp_ic", dynamic:"dyna", dyflag :"df", dyContents :"dc", rectDiffer: "rd", freeCoordinatesLine: "ftcl", //redact overlayCode:"oc", overlayText:"ot", areahi: "areahi",- Type
- object
Example
WebPDF.ViewerInstance.getAnnotDetailJson(1,'50391731-c200-4042-928f-9902fde264d6') result: { "c": "", "ca": 1, "cd": "1537930956", "cl": "#33cc00", "f": 4, "md": "1537930956", "n": "50391731-c200-4042-928f-9902fde264d6", "pop": { "f": 4, "md": "1537930956", "n": "1537930956_popup", "op": 0, "rc": [ 415.5, 746.5, 595.5, 626.5 ] }, "subj": "Underline", "subty": "Underline", "tit": "fz02_90 90", "ty": "Markup", "Quad": [ 221.2, 746.501, 243.196, 746.501, 221.2, 736.097, 243.196, 736.097 ], "rc": [ 221.2, 746.5, 243.2, 736.1 ], "pdf": "false", "del": 0 } -
<static> getAnnotsByType(annotPattern, start, end)
-
Filter out the annotation types in a specified or default range based on the given parameters.
Parameters:
Name Type Description annotPatternWebPDF.Annot.Pattern startNumber The start page index number. The default value is 0.
endNumber The end page index number. The Default value is all pages of current document. Note: This index number is 1 greater than the acutual page number.
Returns:
- Type
- Array.<PDFAnnotDelegator>
-
<static> getContextMenuItemStatus(type, name)
-
Parameters:
Name Type Description typeWebPDF.ContextMenuType nameWebPDF.ContextMenuItemName Returns:
- Type
- Object.<string, boolean>
-
<static> getCurPageIndex()
-
Get the current page index.
Returns:
The Current page index.
- Type
- Number
-
<static> getCurToolHandlerName()
-
Get the current tool handler name.
Returns:
The name of the tool handler.
- Type
- String
-
<static> getCurZoomLevel()
-
Get the current zoom level.
Returns:
The current zoom level value or one of:
WebPDF.ZOOM_FIT_WIDTH = 'FitWidth';
WebPDF.ZOOM_FIT_PAGE = 'FitPage';- Type
- Number | String
-
<static> getFileName()
-
Get the file name of the current PDF document.
Returns:
The file name of the current PDF document.
- Type
- String
-
<static> getMetaData(key)
-
Get metadata of current PDF document.
Parameters:
Name Type Description keyString The key value of the metadata, the value can be as follows:
Title,
Author,
Subject,
Keywords,
Creator,
Producer,
CreationDate(reserved),
ModDate(reserved),
Trapped(reserved)Returns:
metadata value
- Type
- any
-
<static> getPageAnnots(pageIndex, callback)
-
Get the annotation data of specific page in json format.
Parameters:
Name Type Description pageIndexNumber The specified page index.Page index begin at zero.
callbackfunction Callback function after getting annotations of page.
Returns:
{
pageIndex: number,
annots: [
{
name:string,
type:string,
getSubType:string,
title:string,
flag:number,
createTime:string,
modifyTime:string,
contents:string
}
]
}- Type
- Promise.<object>
Example
WebPDF.ViewerInstance.getPageAnnots(0, function(data){....}) -
<static> getPageCount()
-
Get the page count of current document.
Returns:
The page count of current document.
- Type
- Number
-
<static> getPropertyEditorClass(annotPattern)
-
Parameters:
Name Type Description annotPatternWebPDF.Annot.Pattern Returns:
- Type
- class
-
<static> getSelectedAnnots()
-
Returns:
- Type
- Array.<PDFAnnotDelegator>
-
<static> getThumbnail_p(pageIndex)
-
Get the URL of page Thumbnail by the specified page index.
Parameters:
Name Type Description pageIndexNumber The specified page index.the page index is between minimum and max page.
Returns:
The URL of the page Thumbnail.
- Type
- String
-
<static> getUserPermission()
-
Function defined to get user permission.
Returns:
value of user permission. WebPDF.UserPermission
- Type
- Number
Example
WebPDF.ViewerInstance.getUserPermission() return value: -1 Allow all permissions
-
<static> getViewMode()
-
Get current view mode.
Returns:
Current view mode. 0 for continuous page mode,2 for single page mode.
- Type
- Number | *
-
<static> getZoomLevels()
-
Get the list of current available zoom levels.
Returns:
The list of zoom levels.
- Type
- Array.<(Number|String)>
-
<static> gotoNextPage()
-
Go to the next page.
Returns:
True if the next page is exists, else return false.
- Type
- Boolean
-
<static> gotoNextView()
-
Go to the next view.
-
<static> gotoPage(pageIndex [, left] [, top])
-
Jump to a page by the specified page index and the offset to be scrolled to.
Parameters:
Name Type Argument Default Description pageIndexNumber The specified page index.
leftNumber <optional>
0 The left offset that the viewer scrolls to in the device coordinates
topNumber <optional>
0 The top offset that the viewer scrolls to in the device coordinates
Returns:
True if jump to the specified page successful, otherwise, returns false.
- Type
- Boolean
-
<static> gotoPageByAnnot(pageIndex, annotName)
-
Jump to the annotation position on a page by the page number and annotation name.
Parameters:
Name Type Description pageIndexNumber The destination page number where the annotation resides on.
annotNameString The annotation name.
-
<static> gotoPageByDestination(destination)
-
Jump to a page by the specified destination.
Parameters:
Name Type Description destinationWebPDF.PDFDestination The specified destination object.
Returns:
True if jump to the specified destination, else return false.
- Type
- Boolean
Example
WebPDF.ViewerInstance.gotoPageByDestination(new WebPDF.PDFDestination({p:0,l:0,t:100})); -
<static> gotoPrevPage()
-
Go to the previous page.
Returns:
True if the previous page is exist, false for else..
- Type
- Boolean
-
<static> gotoPrevView()
-
Go to the previous view.
-
<static> hasForm()
-
Detect whether the document has form fields.
- Deprecated:
-
- move to FormPlugin
Returns:
True if there is a form field, otherwise, return false.
- Type
- Boolean
-
<static> hideAllAnnots()
-
Hide all current annotations.
Example
WebPDF.ViewerInstance.hideAllAnnots();
-
<static> hideAnnots(annots)
-
Hide annotations.
Parameters:
Name Type Description annotsArray Annotations list for hide
Example
WebPDF.ViewerInstance.getPageAnnots(index, function(pageAnnotsInfo){ var annots = pageAnnotsInfo.annots; if(!annots){ return; } var showOrHideAnnots = []; for(var i =0 ;i<annots.length;i++) { if(annots[i].title == $(_this).val()){ showOrHideAnnots.push(annots[i]); } } WebPDF.ViewerInstance.hideAnnots(showOrHideAnnots); }); -
<static> hidePropertyEditorField(annotPattern, field)
-
Parameters:
Name Type Description annotPatternObject.<string, any> fieldstring -
<static> importAnnotsFromFDF(params)
-
Import annotations to current document from FDF.
This function support the following annotation types:
highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Current support only comments data and not include PDF form data.Parameters:
Name Type Description paramsObject The JSON object contain three parameters as follow.
Properties
Name Type Description typeString 'fileUrl' for http FDF file and 'fileBuffer' for FDF file stream.
fileUrlString File url of http FDF file.
fileBufferUint8Array File buffer with the type Uint8Array.
Example
var params = { type:'fileUrl', fileUrl:'http://localhost:8080/docs/sample/Annot_all.fdf' }; WebPDF.ViewerInstance.importAnnotsFromFDF(params); OR: var params = { type:'fileBuffer', fileBuffer:ArrayBuffer }; WebPDF.ViewerInstance.importAnnotsFromFDF(params); -
<static> importAnnotsFromJson(annotsJson)
-
Import annotation to current document from JSON data.
This function support the following annotation types: highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Current support only comments data and not include PDF form data.Parameters:
Name Type Description annotsJsonArray.<Object> The annotations JSON object.
annotsJson[].numbernumber page index
annotsJson[].annotsArray.<Object> annots for page
The corresponding field of the value type: "ty", flag: "f", rect: "rc", content: "c", name: "n", borderWidth: "bw", borderStyle: "bs", color: "cl", fillColor:"fcl", dash:"d", highlight: "hl", quadPoints: "Quad", destinationInfo: "ds", openState: "op", modifyDate: "md", state: "st", stateModel: "stm", opacity: "ca", creationDate: "cd", subject: "subj", title: "tit", popup: "pop", replyChain: "rpy", stateList: "stat", action: "act", group: "grp", subType: "subty", textAnnotName: "txtn", ft: "ft", defaultAp: "da", fontSize: "fs", fontColor: "fc", fontName: "ftn", lineHeight: "lnh", fontHeight: "fh", textAlign: "q", it: "it", inkList: "ikl", inkColor: "ikc", inkBorderWidth: "ikw", vts: 'vts', lineRect:"l", lineStyle:"le", rotate: "r", pdf:"pdf", del:"del", icon:"stamp_ic", dynamic:"dyna", dyflag :"df", dyContents :"dc", rectDiffer: "rd", freeCoordinatesLine: "ftcl", //redact overlayCode:"oc", overlayText:"ot", areahi: "areahi",Example
WebPDF.ViewerInstance.importAnnotsFromJson([ { "number": 0, "annots": [ { "bs": 0, "c": "Butterflies have been admired for centuries for their physical beauty and behavioural display.", "ca": 1, "cd": "1384916316", "cl": "#ffff00", "f": 28, "md": "1385961736", "n": "c97db9f7-5645-4d06-b5f4-6f9bc91231c2", "pop": { "f": 28, "md": "1384887516", "n": "7f53f835-1c8b-4a2e-80c7-992f9469b58b", "op": 1, "rc": [ 281, 606, 460, 486 ] }, "r": 0, "rc": [ 335.69, 490.19, 355.69, 470.19 ], "subj": "Note", "subty": "Text", "tit": "foxit", "txtn": "Comment", "ty": "Markup" } ] } ]) -
<static> importAnnotsFromXFDF(bufferArray, successCallback)
-
Import annotations to current document from XFDF.
This function support the following annotation types:
highlight,strikeout,underline,squiggly,replace,caret,note,typewriter,callout,textbox,
rectangle,polyline,cloud,oval,arrow,polygon,line,pencil,highlightarea
Current support only comments data and not include PDF form data.Parameters:
Name Type Description bufferArrayUint8Array The xfdf buffer array.
successCallbackfunction The callback after the annotation is successfully imported.Default pop-up prompt succeeded
Example
var url = 'http://localhost:8080/docs/sample/Annot_all.xfdf'; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.send(); xhr.onload = function(e) { var responseArray = new Uint8Array(this.response); WebPDF.ViewerInstance.importAnnotsFromXFDF(responseArray); } -
<static> importFormData(type, buffer)
-
import form data from an Uint8array buffer.
Parameters:
Name Type Description typeString should be one of 'xml', 'fdf', 'xfdf'.
bufferUint8array form data.
Returns:
- Type
- boolean
-
<static> importInkSignFromJson(inkSignData)
-
Import ink signature to current document from JSON data.
Parameters:
Name Type Description inkSignDataObject The ink signature JSON object.
Example
WebPDF.ViewerInstance.importInkSignFromJson([ { "pageIndex": 0, "inkSignList": [ { "isStraddle": false, "pageIndex": 0, "r": 0, "signer": "signer", "dn": "domain", "reason": "", "location": "", "contact": "contactInfo@email.com", "rc": [ 83.766, 455.25, 128.766, 447.75 ], "hash": 1, "subty": "InkSign", "inkData": { "pencil": [ { "color": 0, "width": 33.75, "points": [ [ 83.766, 455.25 ], [ 90.094125, 455.25 ], [ 102.750375, 455.25 ], [ 109.0785, 455.25 ], [ 121.73475, 455.25 ] ] } ], "rect": [ 379.6875, 278.4375, 430.3125, 278.4375 ], "per": 1, "def": 1, "inkSignId": "1528201919" }, "n": "71a95299-ff5b-4cce-ab17-7681edc46f82" } ] } ]) -
<static> insertPagesFromSteam(fileStream, password, pageRanges, insertPos, fileName)
-
Import pages from PDF Stream to current document.
Parameters:
Name Type Description fileStreamUint8Array The PDF file stream of PDF.
passwordString The password of the file related above.
pageRangesString The page ranges to insert, like '1,2-3,4-5', '-1' means insert all pages.
insertPosNumber The page number before which to insert the pages. 0 means insert at the front and -1 mean insert at the end.
fileNameString The fileName of the output file by merging.
Returns:
A Promise object.
-
<static> isDocModified()
-
Check whether current document is modified.
Returns:
True if current document is modified, otherwise, return false.
- Type
- Boolean
-
<static> isFitPage()
-
Check whether the current zoom level is WebPDF.ZOOM_FIT_PAGE.
Returns:
True if the current zoom level is WebPDF.ZOOM_FIT_PAGE, otherwise, return false.
- Type
- Boolean
-
<static> isFitWidth()
-
Check whether the current zoom level is WebPDF.ZOOM_FIT_WIDTH.
Returns:
True if the current zoom level is WebPDF.ZOOM_FIT_WIDTH, otherwise, return false.
- Type
- Boolean
-
<static> isJREngineReady()
-
Check whether Javascript engine is ready.
Returns:
True if the engine is ready, false for else.
- Type
- Boolean
-
<static> off(type [, handler])
-
Removes an event handler from a given event. If the handler is not provided, remove all handlers of the given type.
Parameters:
Name Type Argument Description typeString The name of the event to remove from.
handlerfunction <optional>
The function handler that needs to be removed.
Returns:
Current viewer instance.
-
<static> on(type, handler)
-
Adds a new event handler for a particular type of event.
Parameters:
Name Type Description typeString The name of the event to listen for.
handlerfunction The function to call when the event occurs.
Returns:
Current viewer instance.
- Type
- WebPDF.Viewer
-
<static> one(type, handler)
-
Adds a new event handler for a particular type of event and the handler whill be called only once
Parameters:
Name Type Description typestring The name of the evemt to listen for
handlerfunction The function to call when the event occurs
Returns:
Current viewer instance
- Type
- webPDF.Viewer
-
<static> openFileByStream(fileBuffer, fileId, fileName [, encryptPassword], initializeData)
-
Open PDF file from file stream.
Parameters:
Name Type Argument Description fileBufferUint8Array The file stream with Uint8Array type.
fileIdString The file ID, maybe file md5 or other unique identification.
fileNameString The file name of PDF.
encryptPasswordString <optional>
The encrypted password of the document
initializeDataobject The datas of annotations, 'inkSign' or form to be imported directly after file been opened without permission validation
Properties
Name Type Description annotationsArray.<object> annotations[].numbernumber page index
annotations[].annotsArray.<object> annots for page
inkSignArray.<object> inkSign[].pageIndexnumber inkSign[].inkSignListArray.<object> formobject see also WebPDF.FormPlugin.importFormFromJson
Example
var url = 'http://localhost:8080/doc/sample/1.pdf'; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.send(); xhr.onload = function(e) { var responseArray = new Uint8Array(this.response); var fileId = "Wed, 29 Dec 2010 09:31:20 GMT"; WebPDF.ViewerInstance.openFileByStream(responseArray, fileId, "1.pdf"); } -
<static> openFileByUri(params)
-
Open PDF file by url.
Parameters:
Name Type Description paramsObject The option parameters for open file.
Properties
Name Type Description urlstring the file url
fileIdstring the unique identification of file.
isAsyncModeboolean use the async mode to open the large file, it will improve speed and performance when the PDF file is linearized.
fileSizestring the file size. Required if isAsyncMode is true.
fileNamestring the file name. Required if the url is not suffixed by '.pdf'.
ajaxHeadersObject Be used to set http header by the ajax request to access the url.
initializeDataobject The datas of annotations, 'inkSign' or form to be imported directly after file been opened without permission validation
Properties
Name Type Description annotationsArray.<object> annotations[].numbernumber page index
annotations[].annotsArray.<object> annots for page
inkSignArray.<object> inkSign[].pageIndexnumber inkSign[].inkSignListArray.<object> formobject see also WebPDF.FormPlugin.importFormFromJson
-
<static> print()
-
Do the print process, to open the print dialog.
Returns:
True if the Print dialog is opened, otherwise, return false. One special case is the print to be disabled,return undefined
- Type
- Boolean | undefined
-
<static> redo()
-
Redo the operation (currently this function only supports annotations).
Returns:
None
-
<static> registerPropertyEditor(annotPattern, editorClass)
-
Parameters:
Name Type Description annotPatternObject.<string, any> editorClassclass Returns:
- Type
- class
-
<static> rotate(direction)
-
Rotate current doc view.
Parameters:
Name Type Description directionString The rotation value to rotate the doc view in 90 degrees clockwise or counterclockwise.
The value can be set as one of the following:
WebPDF.ROTATE_LEFT = 'left';
WebPDF.ROTATE_RIGHT = 'right';Returns:
True if rotate success, false for else.
- Type
- Boolean
-
<static> searchText(textToSearch, direction)
-
Search text.
Parameters:
Name Type Description textToSearchString Text to search, the textToSearch ignore case.
directionnumber Direction to search, use one of:
WebPDF.SearchDirection.Up = 0
WebPDF.SearchDirection.Down = 1Returns:
True if search successful, otherwise, return false.
- Type
- Boolean
-
<static> setAnnotContextMenuItemStatus(name, status)
-
Parameters:
Name Type Description nameWebPDF.ContextMenuItemName statusObject Properties
Name Type Argument Default Description visibleboolean <optional>
true disabledboolean <optional>
false -
<static> setContextMenuItemStatus(type, name, status)
-
Parameters:
Name Type Description typeWebPDF.ContextMenuType nameWebPDF.ContextMenuItemName statusObject Properties
Name Type Argument Default Description visibleboolean <optional>
true disabledboolean <optional>
false -
<static> setCurrentToolByName(toolName)
-
Set the current tool by its name.
Parameters:
Name Type Description toolNameString The tool name will be set to one of following:
WebPDF.Tools.TOOL_NAME_HAND
WebPDF.Tools.TOOL_NAME_PAGETEXT
WebPDF.Tools.TOOL_NAME_PINTOOL
WebPDF.Tools.TOOL_NAME_SELANNOT
WebPDF.Tools.TOOL_NAME_TEXTANNOT
WebPDF.Tools.TOOL_NAME_TYPERWRITER
WebPDF.Tools.TOOL_NAME_TEXTBOX
WebPDF.Tools.TOOL_NAME_CALLOUT
WebPDF.Tools.TOOL_NAME_IMAGE
WebPDF.Tools.TOOL_NAME_STAMP
WebPDF.Tools.TOOL_NAME_DRAWING_RECTANGLE
WebPDF.Tools.TOOL_NAME_DRAWING_CIRCLE
WebPDF.Tools.TOOL_NAME_DRAWING_SQUARE
WebPDF.Tools.TOOL_NAME_DRAWING_LINE
WebPDF.Tools.TOOL_NAME_DRAWING_LINEARROW
WebPDF.Tools.TOOL_NAME_DRAWING_CLOUD
WebPDF.Tools.TOOL_NAME_DRAWING_POLYGON
WebPDF.Tools.TOOL_NAME_DRAWING_POLYLINE
WebPDF.Tools.TOOL_NAME_DRAWING_DISTANCE
WebPDF.Tools.TOOL_NAME_MARK
WebPDF.Tools.TOOL_NAME_MARK_APPLY
WebPDF.Tools.TOOL_NAME_COMMENT_HIGHLIGHT
WebPDF.Tools.TOOL_NAME_COMMENT_UNDERLINE
WebPDF.Tools.TOOL_NAME_COMMENT_SQUIGGLY
WebPDF.Tools.TOOL_NAME_COMMENT_STRIKEOUT
WebPDF.Tools.TOOL_NAME_COMMENT_REPLACE
WebPDF.Tools.TOOL_NAME_COMMENT_CARET
WebPDF.Tools.TOOL_NAME_COMMENT_HIGHLIGHT_AREA
WebPDF.Tools.TOOL_NAME_INKANNOT
WebPDF.Tools.TOOL_NAME_INKSIGN
WebPDF.Tools.TOOL_NAME_SELECTTEXT
WebPDF.Tools.TOOL_NAME_HAND
WebPDF.Tools.TOOL_NAME_PAGETEXT
WebPDF.Tools.TOOL_NAME_PINTOOL
WebPDF.Tools.TOOL_NAME_SELANNOT
WebPDF.Tools.TOOL_NAME_TEXTANNOT
WebPDF.Tools.TOOL_NAME_TYPERWRITER
WebPDF.Tools.TOOL_NAME_TEXTBOX
WebPDF.Tools.TOOL_NAME_CALLOUT
WebPDF.Tools.TOOL_NAME_IMAGE
WebPDF.Tools.TOOL_NAME_STAMP
WebPDF.Tools.TOOL_NAME_DRAWING_RECTANGLE
WebPDF.Tools.TOOL_NAME_DRAWING_CIRCLE
WebPDF.Tools.TOOL_NAME_DRAWING_SQUARE
WebPDF.Tools.TOOL_NAME_DRAWING_LINE
WebPDF.Tools.TOOL_NAME_DRAWING_LINEARROW
WebPDF.Tools.TOOL_NAME_DRAWING_CLOUD
WebPDF.Tools.TOOL_NAME_DRAWING_POLYGON
WebPDF.Tools.TOOL_NAME_DRAWING_POLYLINE
WebPDF.Tools.TOOL_NAME_DRAWING_DISTANCE
WebPDF.Tools.TOOL_NAME_MARK
WebPDF.Tools.TOOL_NAME_MARK_APPLY
WebPDF.Tools.TOOL_NAME_COMMENT_HIGHLIGHT
WebPDF.Tools.TOOL_NAME_COMMENT_UNDERLINE
WebPDF.Tools.TOOL_NAME_COMMENT_SQUIGGLY
WebPDF.Tools.TOOL_NAME_COMMENT_STRIKEOUT
WebPDF.Tools.TOOL_NAME_COMMENT_REPLACE
WebPDF.Tools.TOOL_NAME_COMMENT_CARET
WebPDF.Tools.TOOL_NAME_COMMENT_HIGHLIGHT_AREA
WebPDF.Tools.TOOL_NAME_INKANNOT
WebPDF.Tools.TOOL_NAME_NORMALSIG
WebPDF.Tools.TOOL_NAME_CROSSPAGESIG
WebPDF.Tools.TOOL_NAME_INKSIGN
WebPDF.Tools.TOOL_NAME_SELECTTEXTReturns:
True if set current tool successful, else return false.
- Type
- Boolean
-
<static> setCustomWatermark(watermarkInfo)
-
Set the user's watermark information. Please pass in null to remove the watermark
Parameters:
Name Type Description watermarkInfoObject The format of the user's watermark information.
Properties
Name Type Argument Default Description rotationnumber If true, the watermark will be added; otherwise, it will not.
addboolean The rotation degrees of the watermark.
scalenumber The scaling of the watermark.
fontFamilyString The font of the watermark.
contentString The content of the watermark.
colorString | number The color of the watermark.
isDynamicboolean If true, the following will show, according to the specified settings:
IP, User Name, Open Time. Otherwise, it will only show the content inputted by user.userNameboolean If true, will show the User Name when isDynamic is true; otherwise, it will not show.
ipboolean If true, will show IP when isDynamic is true; otherwise, it will not show.
openTimeboolean If true, will show the Open Time when isDynamic is true; otherwise, will not show.
showDirectlyboolean If true, the watermark will be inserted to the document directly when the document opens. If false, the watermark floats over the document.
opacitynumber <optional>
1 0 - 1
-
<static> setLayoutShowMode(mode)
-
Change the page layout mode of the viewer.
Parameters:
Name Type Description modeNumber The page layout mode will be set to one of the following: WebPDF.PDFView.RD_BRMODE_CONTINUOUS
WebPDF.PDFView.RD_BRMODE_SINGLE_PAGE -
<static> setMetaData(key, value)
-
Set metadata of current PDF document;
Parameters:
Name Type Description keyString The key value of the metadata, the value can be as follows:
Title,
Author,
Subject,
Keywords,
Creator,
Producer,
CreationDate(reserved),
ModDate(reserved),
Trapped(reserved)valueString The value to be set as metadata.
Returns:
resolved if set successful, rejected for else.
- Type
- Promise
-
<static> setModifyState(flag)
-
Set the modified state of the current document.
Parameters:
Name Type Description flagBoolean document modified state.
-
<static> setUserPermission(permission)
-
Function defined to set user's permission.
Parameters:
Name Type Description permissionNumber value of user permission.WebPDF.UserPermission
Example
Set only read and download permissions WebPDF.ViewerInstance.setUserPermission(WebPDF.UserPermission.DOCUMENT_VIEW + WebPDF.UserPermission.DOWNLOAD)
-
<static> showAllAnnots()
-
Show all current annotations.
Example
WebPDF.ViewerInstance.showAllAnnots();
-
<static> showAnnots(annots)
-
Show annotations.
Parameters:
Name Type Description annotsArray.<object> Annotations list for show
annots[].namestring Annotations name.
Example
WebPDF.ViewerInstance.showAnnots([ {name: 'bdf5db1c-cd19-4421-a70b-e28babf3f047'} ]); -
<static> showFullPage()
-
Set to display the specified page in full screen mode.
Returns:
True if show full screen success, false for else.
- Type
- Boolean
-
<static> showPropertyEditorField(annotPattern, field)
-
Parameters:
Name Type Description annotPatternObject.<string, any> fieldstring -
<static> splitPages(type)
-
split pages to new documents. If invalied range is specified, only the pages available will be extracted.
Parameters:
Name Type Description typeString The page ranges to be extracted (1-based). It should use digital charaters, '-' and ','. For example, '1,3-4;4-5' means split current document to two which first document contains page one, page three to page four, and second document contains page four and page five.
Returns:
This Promise will pass an object array to resolve(). Each element of this object array has two properties: range: specify the page range of the original document. buffer: splited document's file stream, an Uint8Array.
- Type
- Promise
-
<static> undo()
-
Undo the operation(currently only annotations are supported).
Returns:
None
-
<static> updateLayout(width, height)
-
Update the layout of current viewer instance.
Parameters:
Name Type Description widthNumber New width of viewport.
heightNumber New height of viewport.
-
<static> zoomTo(val)
-
Zoom to the given value.
Parameters:
Name Type Description valfloat | String The given value or the one of the following:
WebPDF.ZOOM_FIT_WIDTH = 'FitWidth';
WebPDF.ZOOM_IN = 'in';
WebPDF.ZOOM_OUT = 'out';
WebPDF.ZOOM_FIT_PAGE = 'FitPage';
If val is a number,It must be within the scope of 0.1 to 6Returns:
If zoom is successful return true, otherwise, return false
- Type
- Boolean