FoxitPDFSDKforWeb v10.0.0
Foxit PDF SDK for Web
PDFViewer Class Reference

Use PDFViewCtrl for the entry file. More...

Inheritance diagram for PDFViewer:
Disposable PDFUI

Public Member Functions

 activateAnnotation (options)
 Jumps to and activates a specified annotation with an option determining if to expand the comment list. More...
 
 activateElement (element)
 Activates an activatable object;. More...
 
 addAnnotationIcon (icon)
 Add an annotation icon. [Not support in Server] More...
 
 addFontMaps (fontMaps)
 Sets a custom font in the viewer for editing PDF text/form field. Before using this function, you should call setJRFontMap() to map the available fonts. More...
 
async close (before=this.customs.closeDocBefore, after=this.customs.closeDocAfter, options={})
 Close the open document. More...
 
async compareDocuments (baseDocId, otherDocId, params, onprogress)
 Compare this PDFDoc with the otherDoc, and then generate a PDFDoc as comparison result. More...
 
 constructor ({ preloadJR=true, preloadSR=false, libPath, jr, sr, i18n, i18nOptions, eventEmitter=new EventEmitter(), minScale=0.01, maxScale=10, defaultScale='fitWidth', scaleFrequency=0, tileSize=1000000, tileCache=2, getTileSize=null, StateHandlers=[], customs={}, keymap={}, Viewmodes=[], enableJS, enableSafeMode, stateHandlerConfig, watermarkConfig, actionOptions={}, defaultViewMode=continuousViewModeName, snapshotServer=new SnapshotServer({ uploadSnapshotAPIPath:'snapshot/upload' }), collaboration={ enable:false, annotationFormat:'fdf', communicator:null, handlerClasses:[], continueToConnect:(retryTimes, shareId)=> {return retryTimes< 15;} }, highPerformance=false, annotRenderingMode, defaultKeyboardEventBinder=VIEWER_BINDER, defaultAnnotConfig, enableSignature, enableShortcutKey=true, enable3DInteraction=true, enableLoad3DModule=true, engineMode=JR, sharedWorker=false, noJSFrame=false, showCommentList=false, showAnnotTooltip=false, showFormFieldTooltip=false, showMeasurementInfoPanel=true, viewerUI, applicationContext, instanceId, messageSyncServiceWorker, }={})
 Create a PDFViewer. More...
 
 convertClientCoordToPDFCoord ({clientX=0, clientY=0})
 An API to get coordinate information for the PDF coordinate system from device coordinates. More...
 
 convertImageToPDFDoc (file, url, title="untitled.pdf", author="", options={}, pdfEngine=this.pdfEngine)
 Convert image to PDF document from file or url, supported image types are bmp/jpeg/png/gif. [Not support in Server] More...
 
 copyAnnots (annots)
 Copy Annotations. No copy in the clipboard. More...
 
 copySnapshot (dataURL)
 Copy image data to clipboard via dataURL. More...
 
 createNewDoc (title="untitled.pdf", author="", pageSize={height:842, width:595}, options={isRenderOnDocLoaded:true}, pdfEngine=this.pdfEngine)
 Create a new pdf document. [Not support in Server] More...
 
 deactivateElement (element)
 Deactives an activatable object;. More...
 
 getActionCallbackManager ()
 Obtains the ActionCallbackManager. More...
 
 getAllActivatedElements ()
 Obtains all activable elements. More...
 
 getAnnotAuthorityManager ()
 Obtains the AnnotationAuthorityManager. More...
 
 getAnnotManager ()
 Get annotation component manager. More...
 
 getAnnotRender (pageIndex, name)
 Get annot render. PDFPageRender::getAnnotRender. More...
 
 getBookmarkDataService ()
 Obtains the BookmarkDataService instance for managing bookmark data. More...
 
 getCurrentPDFDoc ()
 Get current pdf doc object. More...
 
 getCustomOptionsUpdater ()
 Retrieves the CustomOptionsUpdater instance for updating custom options dynamically. More...
 
 getDefaultAnnotConfig ()
 Get the callback function which is used to configure the default settings for the annotations. More...
 
 getEnableJS ()
 Checks if PDF js can be executed. [Not support in Server] More...
 
 getEventEmitter ()
 Get event emitter. More...
 
 getFormHighlightColor ()
 
 getInkSignList (type)
 Get ink signature list. More...
 
 getInstanceId ()
 Get the unique instance ID. More...
 
 getOverlayComparisonOptionsService ()
 Obtains the OverlayComparisonOptionsService, which will be used to configure and share overlay-comparison options between multiple PDFViewer instances and to monitor option changes. More...
 
 getOverlayComparisonService ()
 Obtains the OverlayComparisonService instance, which includes the built-in overlay comparison function. More...
 
 getPDFDocFromImageFile (file, url, title="untitled.pdf", author="")
 
 getPDFDocRender ()
 GetPDFDocRender. More...
 
 getPDFPageRender (index)
 GetPDFPageRender PDFDocRender::getPDFPageRender. More...
 
 getReadAloudService ()
 Obtains the ReadAloudService instance. More...
 
 getRotation ()
 Obtains the rotation degree of curremt document. The result returned is one of these values: 0, 90, 180, 270. More...
 
 getScrollWrap ()
 Obtains the scroll wrap instance. More...
 
 getSnapMode (stateHandlerName)
 Obtains the snap mode by state handler name. More...
 
 getStateHandlerManager ()
 Get state handler manager. More...
 
 getViewModeManager ()
 Get view mode manager. More...
 
 grantEditPDFAPermission (permission)
 Grant permission to edit PDF/A document. More...
 
 grantQueryLocalFontsPermission (permission)
 Grant permission to query local fonts. More...
 
 highlightForm (highlight)
 
 init (selector)
 Initialize PDFViewer. More...
 
 initAnnotationIcons (icons)
 Set initialized annotation icons. Refer to PDFPage.addAnnot to use those icons. [Not support in Server] More...
 
 isLoad3DModuleEnabled ()
 
 isShortcutKeyEnabled ()
 Get shortcut key settings. More...
 
 killFocus ()
 Kill the focus of activated element. More...
 
 loadPDFDocByFile (file, options={})
 Loads and parses the PDF document stream into PDFDoc instance. More...
 
 loadPDFDocByHttpRangeRequest (request, options={})
 Loads either a URL document by HTTP range requests or an entire file depending on if the server enables range request or not. More...
 
 offShortcutKey (shortcut, handler)
 Remove an event handler for the given shortcut. More...
 
 onShortcutKey (shortcut, handler, preventDefaultImplementation=false)
 Add an event handler for the given shortcut. Currently we support shortcut keys:
Esc: Close dialog or exit edit mode or exit search panel.
Home: Jump to the first page.
End: Jump to the last page.
Delete: Delete selected object. Edit mode: delete the selected text object, non-edit mode: delete the selected annot object.
Ctrl+MouseWheelUp: Zoom in the page.
Ctrl+MouseWheelDown: Zoom out the page.
PageUp: Move current view up. When there is a vertical scroll bar.
PageDown: Move current view down. When there is a vertical scroll bar.
UpArrow: Move scroll bar up. When there is a vertical scroll bar.
DownArrow: Move scroll bar down. When there is a vertical scroll bar.
LeftArrow: Move scroll bar the left. When there is a horizontal scroll bar.
RightArrow: Move scroll bar to the right. When there is a horizontal scroll bar.
Enter: Confirm or continue.
Ctrl+Z: Undo. Cmd+Z for Mac.
Ctrl+Y: Redo. Cmd+Shift+Z for Mac.
Ctrl+MouseLeft: Select multiple objects, annotation, path, text edit.
Ctrl+F: Open Search Panel. Cmd+F for Mac.
Ctrl+P: Open Print Panel. Cmd+P for Mac.
Ctrl+RightArrow: Open Left Navigation Panel. Cmd+RightArrow for Mac.
Ctrl+LeftArrow: Close Left Navigation Panel. Cmd+LeftArrow for Mac.
Ctrl+C: Copy annotation(path, text edit,image). Cmd+C for Mac.
Ctrl+X: Cut annotation(text). Cmd+X for Mac.
Ctrl+V: Paste annotation(path, text edit,image). Cmd+V for Mac.
. More...
 
 openPDFByFile (file, options={}, pdfEngine=this.pdfEngine)
 Open the local document. More...
 
 openPDFByHttpRangeRequest (request, options={fileName:''}, pdfEngine=this.pdfEngine)
 Open either a URL document by HTTP range requests or an entire file depending on if the server enables range request or not. More...
 
 openPDFById (id, options={fileName:''})
 Open a document that exists on the server [Server Only]. More...
 
 pasteAnnots (datas)
 Paste annotations into the lower right corner of the center. More...
 
async print ({ isPortfolio, rangeType, pages=[], printType=['page'], progress, printer, showHeaderFooter=this.getPrintSetting('showHeaderFooter'), quality=this.getPrintSetting('quality')||100, }, callback=noop)
 Prints the current document with specified options. Example:

pdfViewer.print({
pages: [0, 1],
printType: ['page', 'annot'],
quality: 100,
showHeaderFooter: false
}, function(message) {
switch(message.state) {
case 'start':
console.log('Start generating page images')
break;
case 'progress':
console.log('Page image URI has been generated', message.pageIndex, message.imageURI, message.total)
break;
case 'end':
console.log('Finish generating page images')
break;
}
})

. More...

 
 printCurrentView ()
 print the currently displayed screen content. Note: If the printed content is spread across pages, calling this interface can't print any content. More...
 
 printEx ({type, pageRange, progress}, callback=noop)
 Prints the current document with specified options. Example:

pdfViewer.printEx({
type: 0,
pageRange: "1,2,5-8",
})

. More...

 
 redraw (force)
 Redraw the currently visible page(s). More...
 
 registerMultimediaPlayers (multimediaPlayers)
 Register the multimedia players. More...
 
 registerPrintHandler (handler)
 Register print handler. More...
 
 registerProgressHandler (callback)
 Register a progress handler. More...
 
 registerSignatureHandler (filter, subfilter, handler)
 Register a signature handler. [Not support in Server] More...
 
 removeAnnotationIcon (type, category, name)
 Remove an custom annotation's icon. [Not support in Server] More...
 
 renderDoc (pdfDoc, scale=this.config.defaultScale)
 Render a loaded PDF document. More...
 
 reopenPDFDoc (pdfDoc, options={})
 When a document fails to open, you can call this method and reproduce the passing parameters to reopen the file that failed to open. More...
 
 rotateTo (degree, options)
 Rotates the current document to the specified degree. This method only changes the rendering of the view and does not change the PDF document data. More...
 
 setActionCallback (ActionCallbackClass)
 Set an ActionCallback class to Web SDK, in aid of performing PDF actions. User should implement a class and call this function to set the action callback to Web SDK. More...
 
 setAutoCalculateFieldsFlag (autoCalculate)
 Provide API to set Automatically Calculate Field Values. More...
 
 setDefaultAnnotConfig (fn)
 Set the default configured callback function for the annotation.See PDFPage::addAnnot for the return object format. More...
 
 setDefaultPrintSetting (printSetting)
 Configures printing parameters. More...
 
 setDocReadColors (colors)
 Sets the background and foreground colors for viewing documents. [Not support in Server] More...
 
 setEnableJS (enable)
 Set whether JavaScript is allowed or not. More...
 
 setEnableLoad3DModule (enable)
 
 setEnableShortcutKey (enable)
 Set whether shortcut key is enabled or disabled. More...
 
 setEraserSize (width)
 Sets the width of the eraser. More...
 
 setFormatOfDynamicStamp (sperator, timeFormat)
 Set dynamic information of stamps. [Not support in Server] More...
 
 setFormCreationContinuously (isContinuous)
 Sets whether to keep the current form field to be created continuously. More...
 
 setFormFieldFocusRectangleVisible (isVisible)
 Set whether form field focus rectangle is visible or not. More...
 
 setFormHighlightColor (color, requiredColor)
 
 setInkSignList (inkSignList)
 Set ink signature list. More...
 
 setJRFontMap (fontMaps)
 Set JR custom font. [Not support in Server] More...
 
 setPencilDrawingTimeOut (millseconds)
 Sets the timeout for the pencil drawing. A new pencil is created beyond the timeout period. More...
 
 setSnapMode (stateHandlerName, mode)
 Set the snap mode that will be used to calculate the point position. More...
 
 setUserName (userName, pdfEngine=this.pdfEngine)
 Set the global username. More...
 
 takeSnapshot (pageIndex, left, top, width, height)
 Capture the picture of the specified area on the page. More...
 
 uploadImage (blob)
 Upload image blob data to the snapshot server, and then returns a same-origin image URL, which can be used to break some browser's limitations. More...
 
 zoomAtPosition (scale, fixedPosition)
 Scale the page with the point of the fixedPosition as the center. More...
 
 zoomTo (scale, position)
 Zoom to the given scale. More...
 
- Public Member Functions inherited from Disposable
 addDestroyHook (...hooks)
 
 destroy ()
 

Public Attributes

HTMLElement element
 A DOM element used to render the stuffs generated in PDFViewer. This element is the DOM node passed by PDFViewer.init method. More...
 
typeof i18next i18n
 I18next instance. More...
 

Detailed Description

Use PDFViewCtrl for the entry file.

var pdfViewer = new PDFViewCtrl.PDFViewer({
jr: {
licenseSN:'FoxitPDFSDKForWeb license SN',
licenseKey:'FoxitPDFSDKForWeb license Key'
}
})
pdfViewer.init('#pdf-viewer');

Member Function Documentation

◆ activateAnnotation()

PDFViewer::activateAnnotation (   options)
inline

Jumps to and activates a specified annotation with an option determining if to expand the comment list.

Parameters
optionsObject
options.annotationIdstring|number - The annotation ID. It is recommended to use object number.
options.pageIndexnumber - The page index where the annotation exists.
[options.showCommentList=false]boolean - Sets whether the comment list should initially open. True value is to open the comment list. This option is only valid for annotations associated with a Popup entry.
Since
7.5.0
function example (pdfViewer) {
var options = {
annotationId: '8aa55b14-9b4c-49ec-97bf-eceedf51ad5b',
pageIndex: 0,
showCommentList: true
};
pdfViewer.activateAnnotation(options)
}

◆ activateElement()

PDFViewer::activateElement (   element)
inline

Activates an activatable object;.

Parameters
elementActivatable

◆ addAnnotationIcon()

PDFViewer::addAnnotationIcon (   icon)
inline

Add an annotation icon. [Not support in Server]

Parameters
iconobject - The annotation's icon.
[icon.fileType]string - The icon's type. It supports png, jpeg, jpg, pdf, bmp, webp.
[icon.url]string - The icon file's URL. It supports HTTP, blob url and base64 url.
[icon.annotType]string - The annotation's type.
[icon.category]string - The icon's category.
[icon.name]string - The icon's name which is a unique identifier.
[icon.width]number - The icon's width.
[icon.height]number - The icon's height.
Note
The special characters is invalid for category and name, such as '~!#$%^&*()=;[]{}'.
Since
7.4.0
Returns
Promise<void>
//GET PDFViewer first.
let pdfviewer = ...
pdfviewer.addAnnotationIcon({
fileType:"png",
url:"http://xxx/xx.png",// or "blob:http://xxxxx"
annotType:'stamp',
category:'logo',
name:'admin',
width:100,
height:45,
})

◆ addFontMaps()

PDFViewer::addFontMaps (   fontMaps)
inline

Sets a custom font in the viewer for editing PDF text/form field. Before using this function, you should call setJRFontMap() to map the available fonts.

Parameters
fontMapsArray<object> - Custom fonts.
fontMapobject - The font information
fontMap.namestring - The font face name.
fontMap.stylenumber - The font styles. Please refer to Font_Styles .
fontMap.charsetnumber - The charset of the font. Please refer to Font_Charset or Font_CIDCharset .
Since
8.0.0
function example (pdfViewer) {
pdfViewer.addFontMaps([
{
"name": "SimSun",
"style": 34,
"charset": 134
}
])
}

◆ close()

async PDFViewer::close (   before = this.customs.closeDocBefore,
  after = this.customs.closeDocAfter,
  options = {} 
)
inline

Close the open document.

Parameters
[before]Function - Callback before closing the document, support Promise, do not close the document when returning false. The default value is the PDFViewer initialization parameter customs.closeDocBefore.
[after]Function - The callback after closing the document. The default value is the PDFViewer initialization parameter customs.closeDocAfter.
Returns
Promise<void>

◆ compareDocuments()

async PDFViewer::compareDocuments (   baseDocId,
  otherDocId,
  params,
  onprogress 
)
inline

Compare this PDFDoc with the otherDoc, and then generate a PDFDoc as comparison result.

Note
This feature is only included in the full package
Parameters
baseDocIdstring - The base document id.
otherDocIdstring - The other document id.
paramsobject - comparison options.
params.basePageRangeComparePageRange - Range of this document pages for comparison.
params.otherPageRangeComparePageRange - Range of other document pages for comparison
[params.baseFileName]string - This pdf document file name. This name will be displayed in the comparison result document, by default the file name of this document is used.
[params.otherFileName]string - Other pdf document file name. This name will be displayed in the comparison result document, by default the file name of other document is used
[params.resultFileName]string - The filename of the comparison result document.
[params.options]object - Comparison options.
[params.options.textOnly=false]boolean - Compare text only. The default is false.
[params.options.detectPage=false]boolean - Detect page deletions or inserts. The default is false.
[params.options.compareTable=false]boolean - Compare table
[params.options.markingColor]MarkingColorValues - Marking colors of each compare type objects.
[params.options.markingColor.delete]number - delete marking color.
[params.options.markingColor.insert]number - insert marking color.
[params.options.markingColor.replace]number - replace marking color.
[params.options.lineThickness]LineThicknessValues - line thickness of each compare type objects.
[params.options.lineThickness.delete]number - delete line thickness.
[params.options.lineThickness.insert]number - insert line thickness.
[params.options.lineThickness.replace]number - replace line thickness.
[params.options.opacity]OpacityValues - Opacity of each compare type objects.
[params.options.opacity.delete]number - delete annot transparency.
[params.options.opacity.insert]number - insert annot transparency.
[params.options.opacity.replace]number - replace annot transparency.
onprogress(currentRate:number)=>void -
Returns
Promise<PDFDoc> - The comparison result PDF document.
Since
8.5.0
const engine = await pdfViewer.getWebPDFJR();
const baseDoc = await engine.loadPDFDocByFile(baseFile);
const otherDoc = await engine.loadPDFDocByFile(otherFile);
const baseDocId = baseDoc.id;
const otherDocId = otherDoc.id;
const params = {
basePageRange: {
end: 7,
from: 0,
},
otherPageRange: {
end: 7,
from: 0,
},
baseFileName: 'baseFile.pdf',
otherFileName: 'otherFile.pdf',
resultFileName: pdfViewer.i18n.t('comparison:resultFileName') || 'The result of comparison.pdf',
options: {
compareTable: false,
detectPage: false,
lineThickness: {
delete: 2,
insert: 2,
replace: 2
},
markingColor: {
delete: 16385285,
insert: 1350655,
replace: 16763904
},
opacity: {
delete: 100,
insert: 100,
replace: 100
},
textOnly: false
}
}
const onprogress = (progress) => {
console.log(progress)
}
const comparedDoc = await pdfViewer.compareDocuments(baseDocId, otherDocId, params, onprogress);
See also
PDFViewer.loadPDFDocByFile
PDFViewer.loadPDFDocByHttpRangeRequest

◆ constructor()

PDFViewer::constructor (   { preloadJR=true, preloadSR=false, libPath, jr, sr, i18n, i18nOptions, eventEmitter=new EventEmitter(), minScale=0.01, maxScale=10, defaultScale='fitWidth', scaleFrequency=0, tileSize=1000000, tileCache=2, getTileSize=null, StateHandlers=[], customs={}, keymap={}, Viewmodes=[], enableJS, enableSafeMode, stateHandlerConfig, watermarkConfig, actionOptions={}, defaultViewMode=continuousViewModeName, snapshotServer=new SnapshotServer({ uploadSnapshotAPIPath:'snapshot/upload' }), collaboration={ enable:false, annotationFormat:'fdf', communicator:null, handlerClasses:[], continueToConnect:(retryTimes, shareId)=> {return retryTimes< 15;} }, highPerformance=false, annotRenderingMode, defaultKeyboardEventBinder=VIEWER_BINDER, defaultAnnotConfig, enableSignature, enableShortcutKey=true, enable3DInteraction=true, enableLoad3DModule=true, engineMode=JR, sharedWorker=false, noJSFrame=false, showCommentList=false, showAnnotTooltip=false, showFormFieldTooltip=false, showMeasurementInfoPanel=true, viewerUI, applicationContext, instanceId, messageSyncServiceWorker, } = {})
inline

Create a PDFViewer.

Parameters
optionsobject - The configuration required to create the PDFViewer.
options.jrobject - JR engine config. [Not support in Server]
[options.jr.licenseKey]string - String of licenseKey information.
[options.jr.licenseSN]string - String of licenseSN information.
[options.jr.l]string - String of license information. If he is assigned a value, neither jr.licenseKey nor jr.licenseSN is valid
[options.jr.workerPath=options.libPath]string - The JR engine worker path.
If it's a relative path, it's relative to "options.libPath".
If it's url, it's url.
[options.jr.enginePath=options.libPath+'jr-engine']string - The JR engine path.
If it's a relative path, it's relative to "options.libPath".
If it's url, it's url.
[options.jr.fontPath='../external/brotli']string - The JR engine render fonts path. If it's a relative path, it's relative to "options.libPath".
If it's url, it's url. If you don't want the font resources under external/brotil, you can use the fonts on our server by configuring http://webpdf.foxitsoftware.com/webfonts
[options.jr.fontInfoPath]string - The url of the fonts information file.
[options.jr.readBlock=8192]number - Size of each read block. default 8192 = 8 *1024 = 8KB
[options.jr.brotli]object - brotli config
[options.jr.brotli.core]boolean - This parameter is used to set whether to use brotli compression or not. This is specially useful on a legacy browser but with high-speed network. True is the default value which means to enable the brotli loading.
[options.preloadJR=true]boolean - Preload JR engine. [Not support in Server]
[options.libPath]string - DFViewer lib package path. The default is the current page path.
[options.minScale=0.01]number - Minimum magnification
[options.maxScale=10]number - Maximum magnification
[options.defaultScale='fitWidth']number|string - Multiple of the default display. string enum: fitWidth, fitHeight
[options.scaleFrequency=0]number - Set integers greater than or equal to 0. It will affect page rendering.
The default value is 4, then 1/4=0.25, such as 1.1 times, is 1.25 times the size of the picture to reduce drawing overhead.
The larger the value, the clearer it is, but the higher the performance penalty. If the value is set to 0, it is rendered in raw multiples, not scaled. The biggest performance penalty.
[options.tileSize=1200]number - Deprecated. Starting in version 8.5, this option has been deprecated.
[options.tileCache=2]boolean|number - If the tile caching is enabled, tiles that scroll outside the viewport are retained, while if positive, the number of tiles scrolling outside the window is retained the corresponding number of pages is retained, if it is not positive, it is disabled, while if disabled, tiles scrolling outside the viewport will be cleared and need to be re-rendered. Clearing the cache can reduce the rendering quality, but save memory.
[options.getTileSize=null]Function - Deprecated. Starting in version 8.5, this option has been deprecated.
[options.annotRenderingMode]object - Deprecated. Starting in version 8.5, this option has been deprecated. By default, Foxit PDF SDK for Web uses the native mode (using WebAssembly as the rendering engine) to render annotations and form controls.
[options.i18n]typeof i18next - 18next instance https://www.i18next.com/
[options.i18nOptions]object - If options.i18n does not exist, options.i18n is generated through the options.i18nOptions configuration
[options.i18nOptions.initOption={ns:'viewer_'}]object - Multilingual config. https://www.i18next.com/overview/configuration-options
[options.i18nOptions.path=options.libPath+'locales']string - Multilingual path.
If it's a relative path, it's relative to options.lib.
If it's url, it's url.
[options.eventEmitter]EventEmitter - default: new EventEmitter(); eventemitter3 https://github.com/primus/eventemitter3
[options.Viewmodes=[]]Array<new(pdfDocRender: PDFDocRender)=>IViewMode> - View mode component.
[options.defaultViewMode='continuous-view-mode']string - The default view mode to display PDF pages.
Available view mode name literals: 'continuous-view-mode','single-page-view-mode', and the name of options.Viewmodes.
'facing-page-view-mode', 'h-continuous-view-mode' and 'facing-continuous-page-view-mode' are defined in h-continuous uix addon, it works in UIExtension module only!
[options.defaultAnnotConfig=function(type,intent){}]Function - Gets the default configured callback for the annotation.See PDFPage::addAnnot for the return object format.
[options.customs]object - Custom component.
[options.customs.closeDocBefore=function(){}]Function - Callback before closing the document, support Promise, do not close the document when returning false.
[options.customs.closeDocAfter=function(){}]Function - Callback after closing the document, support Promise.
[options.customs.getDocPermissions=(doc:PDFDoc)=>-1]Function - Get custom user access permissions. -1 represents all permissions. Please refer to User_Permissions
[options.customs.getAdditionalPerm=(doc:PDFDoc)=>-1]Function - Get additional permissions. Please refer to Additional_Permission.
[options.customs.getAnnotPermissions=(annot:Annot)=>Promise.resolve()]Function - A function used to generate a permission list(Refer to PDFViewCtrl.constants.ANNOTATION_PERMISSION ) base on the annotation information. The application can control the permissions of each annotation according to actual needs through this function.
[options.customs.ScrollWrap=ScrollWrap]new(...args:any[])=>ScrollWrap - The component that controls the roll.
[options.customs.PDFViewerRendering]PDFViewerRendering - Called when the viewer rendering.
[options.customs.PDFDocRendering]PDFDocRendering - Called when the doc rendering.
[options.customs.PDFPageRendering]PDFPageRendering - Called when the page rendering.
[options.customs.AnnotTooltip]AnnotTooltip - The component that controls the tooltip.
[options.customs.beforeRenderPDFDoc](pdfDoc:PDFDoc)=>Promise<void> - Called before render PDF document when opening file.
[options.customs.getAnnotComponentConfig=function(){}](annotComponent:AnnotComponent, props:Array<String>)=>object - Configure configuration items for the AnnotComponent. The details of the configuration items refer to the AnnotComponentConfig.
This can be set using CustomOptionsUpdater.updateGetAnnotComponentConfig.
js
const pdfui = new PDFUI({
viewerOptions: {
customs: {
getAnnotComponentConfig: function (annotComponent, props) {
let annot = annotComponent.getModel();
if (annot.getType() !== 'stamp') {
return;
}
let config = {};
props.forEach(function (key) {
switch (key) {
case 'resizable':
config[key] = false;
break;
}
})
return config;
}
}
}
})
[options.customs.storageDriver]StorageDriver - Custom storage driver instance.
[options.customs.syncTextScaling=false]boolean - Determines whether the text size inside the free text box/callout should scale synchronously with outer container.
[options.customs.getLocalFontMapFromCache=(pdfViewer:PDFViewer)=>Promise<{blobs:Blob[],infos:String[]}>]Function - Get the local font map from the cache.By default, the cached data is retrieved from indexeddb
[options.customs.setLocalFontMapFromCache=(pdfViewer:PDFViewer,blobs:Blob[],infos:String[])=>Promise]Function - Set the local font map to the cache. By default, the data is cached in indexeddb.
[options.customs.createLocalFontProgress=(pdfViewer:PDFViewer)=>function(progress:number){}]Function - Create a local font progress bar. progress is a number between 0 and 1. -1 failed, 1 success.
[options.customs.confirmLocalFont=(pdfViewer:PDFViewer)=>Promise<boolean>]Function - Confirm the local font.
[options.StateHandlers=[]]IStateHandler[] - pdf viewer state handler.
[options.enableShortcutKey=true]boolean - Enable or disable shortcut key.
[options.noJSFrame=false]boolean - Specifies whether using a iframe DOM to run PDF JS. True means PDF JS is running in a separated iframe DOM. Otherwise running in same frame.If multiple PDFViewer instances exist at the same time, this parameter will be forced to false.
[options.showCommentList=false]boolean - Specifies whether commentList pops up after add a new markup annotation.
[options.showAnnotTooltip=false]boolean - Specifies whether a Tooltip is used or not used.
[options.showFormFieldTooltip=false]boolean - Specifies whether a Tooltip is used or not used for form fields.
[options.collaboration]object - Specify collaboration parameters. Deprecated. Starting in version 8.5.2, this option has been deprecated. Using Foxit web collaboration add-on instead. Please refer to https://webviewer-demo.foxit.com/docs/collab-developer-guide/ for more details.
[options.collaboration.enable]boolean - Whether to enable collaboration. Deprecated. Starting in version 8.5.2, this option has been deprecated.
[options.collaboration.communicator]CollaborationCommunicator - A communicator used to communicat with the server. Deprecated. Starting in version 8.5.2, this option has been deprecated.
[options.collaboration.continueToConnect](retryTimes:number, shareId:string)=>boolean - A callback used to detect whether to reconnect more times on connection losted! Deprecated. Starting in version 8.5.2, this option has been deprecated.
[options.viewerUI]IViewerUI - Used to customize the UI components that needed within the PDFViewer
[options.snapshotServer]SnapshotServer - Used to customize screenshot image storage service
[options.showMeasurementInfoPanel=true]boolean - Specifies whether the measurement information panel pops up after activate an measurement.
[options.instanceId]String - The ID of the instance used to differentiate between multiple instances. This is typically used to isolate storage space for different instances. This parameter is optional. When instanceId is not specified, the SDK will automatically generate an instanceId based on the creation order of PDFViewer. If instanceId is specified, it will be checked for duplicates. If there are any PDFViewer instances that have not been destroyed and are using the same instanceId, an exception will be thrown. If there are no duplicates, the specified instanceId will be used
[options.messageSyncServiceWorker]object - Options for customizing the configuration of the service worker that will be used for SDK internal communication. This was added in version 10.0.0.
[options.messageSyncServiceWorker.registration]Promise<ServiceWorkerRegistration> - A Promise that resolves with a ServiceWorkerRegistration object returned from navigator.serviceWorker.register.
[options.messageSyncServiceWorker.url]string - The URL of the service worker script, If registration option is provided, this option will be omitted.
[options.messageSyncServiceWorker.options]RegistrationOptions - An object containing registration options(https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#options), If the registration is provided, this option will be omitted.
property i18n
{i18next} - i18next instance
property customs
{object} - Custom component.
property config
{object} - { jr: options.jr, licenseKey: options.licenseKey, licenseSN: options.licenseSN, minScale: options.minScale, maxScale: options.maxScale, defaultViewMode: options.defaultViewMode, }
property eventEmitter
{EventEmitter} - pdfViewer EventEmitter
eventemitter3 https://github.com/primus/eventemitter3

◆ convertClientCoordToPDFCoord()

PDFViewer::convertClientCoordToPDFCoord (   {clientX=0, clientY=0})
inline

An API to get coordinate information for the PDF coordinate system from device coordinates.

Parameters
clientXnumber - the X-axis offset in the upper-left corner of the browser view.
clientYnumber - the Y-axis offset in the upper-left corner of the browser view.
Since
7.5
function example (pdfViewer) {
pdfViewer.convertClientCoordToPDFCoord({clientX:e.srcEvent.clientX, clientY:e.srcEvent.clientY}).then(poi=>{
//do something
})
}
Returns
Promise<{index: number, left: number, top: number, scale: number, rotation: number} | null> - A Promise that resolves with an object containing the converted coordinates or null if conversion fails.
index: current page index.
top: The Y-axis offset in the upper-left corner of the page in the PDF coordinate.
left: The X-axis offset in the upper-left corner of the page in the PDF coordinate.
scale: The specific scale of the page.
rotation: The specific rotate of the page.

◆ convertImageToPDFDoc()

PDFViewer::convertImageToPDFDoc (   file,
  url,
  title = "untitled.pdf",
  author = "",
  options = {},
  pdfEngine = this.pdfEngine 
)
inline

Convert image to PDF document from file or url, supported image types are bmp/jpeg/png/gif. [Not support in Server]

Since
7.4.0
Note
The output PDF document will not be rendered, please call PDFViewer::renderDoc if requires.
Parameters
fileFile|Blob|ArrayBuffer - File stream of image file, if it is null or undefined, the parameter 'url' will be used.
urlstring - Request the url of the file, this parameter would be ignore if parameter 'file' is valid.
It's the second parameter to XMLHttpRequest.open,this URL is relative to the path of your HTML page.
titlestring - New pdf title, default value is "untitled.pdf".
authorstring - New Pdf author.
[options]object - reserved.
[pdfEngine]any - If you have a custom engine, pass it here.
Returns
Promise<PDFDoc> - PDF document object. reject: An Error object which contains the error message.
//The following example converts an image file to pdf document, then render the converted document.
function example (pdfViewer) {
return pdfViewer.convertImageToPDFDoc(file, null).then(
(pdfDoc) => {
return pdfViewer.renderDoc(pdfDoc);
}
);

◆ copyAnnots()

PDFViewer::copyAnnots (   annots)
inline

Copy Annotations. No copy in the clipboard.

Note
Not support strikeout, highlight, squiggly, underline, redact, caret, screen, sound, popup annotations, and signature field.
Parameters
annotsArray<Annot> -
Returns
object[] - Annots information.
[{
type,// { string } Type.
rect,// { PDFRect } Rect.
id, // { number } [Not widget] Id.
pageIndex, // {number} [Not widget] Page index.
fieldName, // {string} [Widget] Field name.
fieldType, // {number} [Widget] Field type.
objectNumber, // {number} [Widget] Field objectNumber.
}]
Since
8.3
async function example(pdfViewer){
var doc = pdfViewer.getCurrentPDFDoc()
var page = await doc.getPageByIndex(0)
var annots = await page.getAnnots();
pdfViewer.copyAnnots([annots[0]])
}

◆ copySnapshot()

PDFViewer::copySnapshot (   dataURL)
inline

Copy image data to clipboard via dataURL.

Note
This method must be called from inside a short running user-generated event handler because of some browser's restriction, such as firefox. Otherwise, because access clipboard data requires a secure origin, so need HTTPS or localhost.
Parameters
dataURLstring - Image data URL
Returns
Promise<boolean> - True if success, otherwise false.
Since
8.2.0

◆ createNewDoc()

PDFViewer::createNewDoc (   title = "untitled.pdf",
  author = "",
  pageSize = {height:842, width:595},
  options = {isRenderOnDocLoaded:true},
  pdfEngine = this.pdfEngine 
)
inline

Create a new pdf document. [Not support in Server]

Parameters
titlestring - New pdf title, default value is "untitled.pdf".
authorstring - New Pdf author.
[pageSize={height:842,width:595}]{height:number,width:number} - default: {height:842, width:595}.
[options={isRenderOnDocLoaded:true}]object - Whether to render the document when it has been loaded.
[options.isRenderOnDocLoaded=true]boolean -
[pdfEngine]any - If you have a custom engine, pass it here
Returns
Promise<PDFDoc> - PDF document object

◆ deactivateElement()

PDFViewer::deactivateElement (   element)
inline

Deactives an activatable object;.

Parameters
elementActivatable

◆ getActionCallbackManager()

PDFViewer::getActionCallbackManager ( )
inline

Obtains the ActionCallbackManager.

Returns
ActionCallbackManager -
function example(pdfViewer){
return pdfViewer.getActionCallbackManager();
}
Since
9.1.0

◆ getAllActivatedElements()

PDFViewer::getAllActivatedElements ( )
inline

◆ getAnnotAuthorityManager()

PDFViewer::getAnnotAuthorityManager ( )
inline

◆ getAnnotManager()

PDFViewer::getAnnotManager ( )
inline

Get annotation component manager.

Returns
ViewerAnnotManager

◆ getAnnotRender()

PDFViewer::getAnnotRender (   pageIndex,
  name 
)
inline

Get annot render. PDFPageRender::getAnnotRender.

Parameters
pageIndexnumber - page index
namestring|number - annotation name, It is recommended to use object number.
Returns
AnnotRender|null - Returns null if the annotation has‘t been rendered.

◆ getBookmarkDataService()

PDFViewer::getBookmarkDataService ( )
inline

Obtains the BookmarkDataService instance for managing bookmark data.

This method provides access to the singleton instance of BookmarkDataService, allowing for the management and manipulation of bookmark-related data.

Returns
BookmarkDataService - The singleton instance of the BookmarkDataService.
Since
10.0.0

◆ getCurrentPDFDoc()

PDFViewer::getCurrentPDFDoc ( )
inline

Get current pdf doc object.

Returns
PDFDoc|null - Null is returned when the document is not currently open
Examples:
/builds/foxit/phantom/cloud/phantompdf_online/foxitwebsdk/doxygen/workspace/headerfiles/uix-addons/thumbnail/thumbUIComponent.js.

◆ getCustomOptionsUpdater()

PDFViewer::getCustomOptionsUpdater ( )
inline

Retrieves the CustomOptionsUpdater instance for updating custom options dynamically.

Returns
CustomOptionsUpdater - The CustomOptionsUpdater instance.
Since
9.1.0

◆ getDefaultAnnotConfig()

PDFViewer::getDefaultAnnotConfig ( )
inline

Get the callback function which is used to configure the default settings for the annotations.

Returns
(type:string,intent:string)=>object - The default configured callback function. See PDFViewer::setDefaultAnnotConfig .
function example (pdfViewer) {
pdfViewer.getDefaultAnnotConfig()
}
Since
8.4.0

◆ getEnableJS()

PDFViewer::getEnableJS ( )
inline

Checks if PDF js can be executed. [Not support in Server]

Returns
boolean - True allows JavaScript to execute, and false does the opposite

◆ getEventEmitter()

PDFViewer::getEventEmitter ( )
inline

Get event emitter.

Returns
EventEmitter

◆ getFormHighlightColor()

PDFViewer::getFormHighlightColor ( )
inline

Get the highlight color for form field.

Returns
{color:number, colorRequired:number} -
  • color {number} - The highlight color. Format: 0xAARRGGBB.
  • requiredColor {number} -. The highlight color for the fields which contains the 'required' flag. Format: 0xAARRGGBB.
Since
7.5.0
function example (pdfViewer) {
let {color, colorRequired} = pdfViewer.getFormHighlightColor();
return {color, colorRequired};
}

◆ getInkSignList()

PDFViewer::getInkSignList (   type)
inline

Get ink signature list.

Parameters
typestring - Custom format of export the ink signature, it should be the one of 'base64' and 'blob'; The default value is 'base64'.
Returns
object[] -
function example (pdfViewer) {
pdfViewer.getInkSignList('blob');
}
Since
7.4.0

◆ getInstanceId()

PDFViewer::getInstanceId ( )
inline

Get the unique instance ID.

The value of this ID is dependent on the construction order of the PDFViewer instance by default. After page reload, this value remains unchanged.

Returns
string|undefined - The unique instance ID as a string.
Since
9.1.0

◆ getOverlayComparisonOptionsService()

PDFViewer::getOverlayComparisonOptionsService ( )
inline

Obtains the OverlayComparisonOptionsService, which will be used to configure and share overlay-comparison options between multiple PDFViewer instances and to monitor option changes.

Returns
OverlayComparisonOptionsService
Since
9.0.0

◆ getOverlayComparisonService()

PDFViewer::getOverlayComparisonService ( )
inline

Obtains the OverlayComparisonService instance, which includes the built-in overlay comparison function.

Returns
OverlayComparisonService
Since
9.0.0

◆ getPDFDocFromImageFile()

PDFViewer::getPDFDocFromImageFile (   file,
  url,
  title = "untitled.pdf",
  author = "" 
)
inline

Convert image file to PDFdoc object supported image types are bmp/jpeg/png/gif.

◆ getPDFDocRender()

PDFViewer::getPDFDocRender ( )
inline

GetPDFDocRender.

Returns
PDFDocRender|null - Returns null when not found.
Examples:
/builds/foxit/phantom/cloud/phantompdf_online/foxitwebsdk/doxygen/workspace/headerfiles/uix-addons/thumbnail/thumbUIComponent.js.

◆ getPDFPageRender()

PDFViewer::getPDFPageRender (   index)
inline

GetPDFPageRender PDFDocRender::getPDFPageRender.

Parameters
indexnumber - page index
Returns
PDFPageRender|null - Returns null when not found.

◆ getReadAloudService()

PDFViewer::getReadAloudService ( )
inline

Obtains the ReadAloudService instance.

Returns
ReadAloudService
Since
8.0.0

◆ getRotation()

PDFViewer::getRotation ( )
inline

Obtains the rotation degree of curremt document. The result returned is one of these values: 0, 90, 180, 270.

Since
7.4.0
Returns
number
See also
PDFViewer::rotateTo

◆ getScrollWrap()

PDFViewer::getScrollWrap ( )
inline

Obtains the scroll wrap instance.

Since
7.6.0
Returns
ScrollWrap

◆ getSnapMode()

PDFViewer::getSnapMode (   stateHandlerName)
inline

Obtains the snap mode by state handler name.

Parameters
stateHandlerNamestring - State handler name which supports snap mode:
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_LINE
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_ARROW
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_DISTANCE
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_PERIMETER
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_AREA
Returns
SNAP_MODE[] - If the specified state handler name does not set snap mode, an empty array is returned
Since
7.6.0

◆ getStateHandlerManager()

PDFViewer::getStateHandlerManager ( )
inline

Get state handler manager.

Returns
StateHandlerManager -

◆ getViewModeManager()

PDFViewer::getViewModeManager ( )
inline

Get view mode manager.

Returns
ViewModeManager - Instance of ViewModeManager

◆ grantEditPDFAPermission()

PDFViewer::grantEditPDFAPermission (   permission)
inline

Grant permission to edit PDF/A document.

Parameters
permissionstring - The permission name. The value is one of 'granted', 'denied', 'prompt'. default is 'prompt'.
'granted' - The user has given express permission to edit PDF/A document.
'denied' - The user has denied access to edit PDF/A document.
'prompt' - The user has not given express permission to edit PDF/A document. It also means that if a caller attempts to edit PDF/A document, the user agent will either be prompting the user for permission or access to edit PDF/A document will be denied.
Returns
void
Since
10.1.0
Example:
function example(pdfViewer){
pdfViewer.grantEditPDFAPermission('granted')
}

◆ grantQueryLocalFontsPermission()

PDFViewer::grantQueryLocalFontsPermission (   permission)
inline

Grant permission to query local fonts.

Parameters
permissionstring - The permission name. The value is one of 'granted', 'denied', 'prompt'. default is 'prompt'.
'granted' - The user has given express permission to query local fonts.
'denied' - The user has denied access to query local fonts.
'prompt' - The user has not given express permission to query local fonts. It also means that if a caller attempts to query local fonts, the user agent will either be prompting the user for permission or access to query local fonts will be denied.
Since
10.1.0

◆ highlightForm()

PDFViewer::highlightForm (   highlight)
inline

Sets if to highlight the form or not. [Not support in Server]

Parameters
highlightboolean - Specifies whether the form field should be highlighted or not. true for showing highlight color. false for not showing.
Since
7.4.0

◆ init()

PDFViewer::init (   selector)
inline

Initialize PDFViewer.

Parameters
selectorstring|HTMLElement - Jquery selector. PDFViewer dom host.

◆ initAnnotationIcons()

PDFViewer::initAnnotationIcons (   icons)
inline

Set initialized annotation icons. Refer to PDFPage.addAnnot to use those icons. [Not support in Server]

Example:
function example(pdfViewer) {
pdfViewer.initAnnotationIcons([{
annotType: 'stamp'
category: 'category1',
name: 'name1',
url:"xxx://xxx.png",
fileType:"png",
width:150,
height:45
}, {
annotType: 'stamp'
category: 'category1',
name: 'name2',
url:"xxx://xxx.jpg",
fileType:"jpg"
}])
}
Note
This setting is valid after the document is opened. If call this function to set initialized annotation icons, defaults icons of UIExtension will be replaced.
Parameters
iconsArray - Icons for annotations
[icons.annotType='stamp']string - The annotation's type, currently only 'stamp' available
icons.categorystring - The icon's category.
icons.namestring - The icon's name which is a unique identifier.
icons.fileTypestring - The icon's type. It supports bmp, jpg, jpeg, png, webp, tif, tiff, pdf.
icons.urlstring - The icon file's URL. It supports HTTP, blob url and base64 url. Relative path and absolute path are not supported.
[icons.width=150]number - The icon's width in PDF coordinates, default:150
[icons.height=45]number - The icon's height in PDF coordinates, default: 45.
Note
Starting in version 9.1, the parameter types have been adjusted to use an array format. The previous parameter type usage is as follows:
{
stamp:{ // annot type, currently only 'stamp' available.
category1:{// Collection of icons
name1: { // name of icon
url:"xxx://xxx.png",//url for icon. It supports HTTP, blob url and base64 url.
fileType:"png",//Icon file type. 'bmp', 'jpg', 'jpeg', 'png', 'webp', 'tif', 'tiff' and 'pdf' available. For 'tif', 'tiff' and 'pdf', a svg file url with the same prefix should also be provided for display in the stamp list.
width:150,//icon's width in PDF coordinates, default:150,
height:45//icon's height in PDF coordinates, default:45,
}
name2:{
...
}
}
category2:{
...
}
}
}
The special characters is invalid for category and name, such as '~!#$%^&*()-=;:[]{}'.
Returns
Promise<void>
Since
7.4.0

◆ isLoad3DModuleEnabled()

PDFViewer::isLoad3DModuleEnabled ( )
inline

Get whether the 3D module is enabled to be loaded.

Returns
boolean - True for 3D module enabled to be loaded, false for 3D module disabled to be loaded.
Since
10.0.0

◆ isShortcutKeyEnabled()

PDFViewer::isShortcutKeyEnabled ( )
inline

Get shortcut key settings.

Returns
boolean - True for shortcut key enabled, false for shortcut key disabled.
Since
7.4.0

◆ killFocus()

PDFViewer::killFocus ( )
inline

Kill the focus of activated element.

Since
7.3.0
Returns
Promise<boolean> - True for success.

◆ loadPDFDocByFile()

PDFViewer::loadPDFDocByFile (   file,
  options = {} 
)
inline

Loads and parses the PDF document stream into PDFDoc instance.

Note
This function is used when a document only needs to be loaded and not displayed.
Parameters
fileFile|Blob|ArrayBuffer|TypedArray|DataView - File stream of PDF document
optionsobject
[options.password]string - document password
[options.encryptPassword]string - The document's password is encrypted again. You can refer to the logic of path 'server/encrypt-password' to get your encryptPassword [Not support in Server]
[options.fileName='']string - document filename
[options.readBlock]number - Size of each read block. default equals options.jr.readBlock. [Not support in Server]
[options.errorHandler](doc:PDFDoc,options:object,error:any|undefined,retry:(options:object)=>Promise<PDFDoc|undefined>)=>Promise<PDFDoc|undefined> - An optional callback function for handling exceptions. When a password error occurs, you can use this callback function to accept a new password and continue to open the document.
[options.drm]object - When this value is set, the DRM decryption process is invoked. [Not support in Server]
[options.drm.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.drm.subFilter]string - The sub filter of PDF document.
[options.drm.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.drm.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.drm.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.drm.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.drm.fileId]string - The file identity string.
[options.drm.initialKey]string - The user specified initial key for encryption.
[options.fileOpen]object - When this value is set, the fileOpen decryption process is invoked. [Not Support in Server]
[options.fileOpen.encryptKey]string[] - Decrypt an array of charcodes for the key
[options.fileOpen.cipher]Cipher_Type[] - The cipher type. Default: Cipher_Type::cipherRC4 , Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type.cipherNone
[options.jwt]Function - Invalid parameter Must be filled when JWT calibration is enabled. [Server Only]
Returns
Promise<PDFDoc|undefined> - The PDFDoc instance, or undefined if the document format or entered password is wrong.
Since
8.3.0

◆ loadPDFDocByHttpRangeRequest()

PDFViewer::loadPDFDocByHttpRangeRequest (   request,
  options = {} 
)
inline

Loads either a URL document by HTTP range requests or an entire file depending on if the server enables range request or not.

Note
This function is used when a document only needs to be loaded and not displayed.
Parameters
requestobject
request.rangeobject - HTTP range requests, responseType = 'arraybuffer'.
request.range.urlstring - Request the url of the file. The second parameter to XMLHttpRequest.open, default request.range.url, this URL is relative to the path of your HTML page.
[request.range.type='GET']number - The first parameter to XMLHttpRequest.open, default GET.
[request.range.user]number - The fourth parameter to XMLHttpRequest.open.
[request.range.password]number - The fifth parameter to XMLHttpRequest.open.
[request.range.headers]object - Set the request header for XMLHttpRequest. eg: XMLHttpRequest.setRequestHeader(x, request.header.headers.x).
[request.range.chunkSize=131072]number - Size of each Range sharding request. default 131072 = 128 *1024 = 128KB. [Not support in Server]
[request.range.extendOptions]string - Set the response header to get additional options. [Not support in Server]
[request.size]number - The size of the document. [Not support in Server]
optionsobject
[options.password]string - Document password.
[options.encryptPassword]string - The document's password is encrypted again. You can refer to the logic of path 'server/encrypt-password' to get your encryptPassword. [Not support in Server]
[options.fileName='']string - Document filename.
[options.readBlock]number - Size of each read block. default equals options.jr.readBlock. [Not support in Server]
[options.errorHandler](doc:PDFDoc,options:object,error:any|undefined,retry:(options:object)=>Promise<PDFDoc|undefined>)=>Promise<PDFDoc|undefined> - An optional callback function for handling exceptions. When a password error occurs, you can use this callback function to accept a new password and continue to open the document.
[options.drm]object - When this value is set, the DRM decryption process is invoked. [Not support in Server]
[options.drm.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.drm.subFilter]string - The sub filter of PDF document.
[options.drm.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.drm.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.drm.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.drm.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.drm.fileId]string - The file identity string.
[options.drm.initialKey]string - The user specified initial key for encryption.
[options.fileOpen]object - When this value is set, the fileOpen decryption process is invoked. [Not Support in Server]
[options.fileOpen.encryptKey]string[] - Decrypt an array of charcodes for the key.
[options.fileOpen.cipher]Cipher_Type[] - The cipher type. Default: Cipher_Type::cipherRC4 , Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type.cipherNone
[options.jwt]Function - Invalid parameter. Must be filled when JWT calibration is enabled. [Server Only]
Returns
Promise<PDFDoc|undefined> - The PDFDoc instance, or undefined if the document format or entered password is wrong.
Since
8.3.0

◆ offShortcutKey()

PDFViewer::offShortcutKey (   shortcut,
  handler 
)
inline

Remove an event handler for the given shortcut.

Parameters
shortcutstring - A keyboard shortcut key.
[handler]Function|object - If not passed, all handlers of the given shortcut will be removed.
Since
7.4.0
function example (pdfViewer) {
// this will remove all handlers for ctrl+a
pdfViewer.offShortcutKey('ctrl+a');
// this will remove specific keydown handler for ctrl+a
pdfViewer.offShortcutKey('ctrl+a', handler);
// this will remove specific keyup handler and all keydown handlers for ctrl+a
pdfViewer.offShortcutKey('ctrl+a', {
keydown: undefined,
keyup: handler,
});
}
Examples:
/builds/foxit/phantom/cloud/phantompdf_online/foxitwebsdk/doxygen/workspace/headerfiles/uix-addons/thumbnail/thumbUIComponent.js.

◆ onShortcutKey()

PDFViewer::onShortcutKey (   shortcut,
  handler,
  preventDefaultImplementation = false 
)
inline

Add an event handler for the given shortcut. Currently we support shortcut keys:
Esc: Close dialog or exit edit mode or exit search panel.
Home: Jump to the first page.
End: Jump to the last page.
Delete: Delete selected object. Edit mode: delete the selected text object, non-edit mode: delete the selected annot object.
Ctrl+MouseWheelUp: Zoom in the page.
Ctrl+MouseWheelDown: Zoom out the page.
PageUp: Move current view up. When there is a vertical scroll bar.
PageDown: Move current view down. When there is a vertical scroll bar.
UpArrow: Move scroll bar up. When there is a vertical scroll bar.
DownArrow: Move scroll bar down. When there is a vertical scroll bar.
LeftArrow: Move scroll bar the left. When there is a horizontal scroll bar.
RightArrow: Move scroll bar to the right. When there is a horizontal scroll bar.
Enter: Confirm or continue.
Ctrl+Z: Undo. Cmd+Z for Mac.
Ctrl+Y: Redo. Cmd+Shift+Z for Mac.
Ctrl+MouseLeft: Select multiple objects, annotation, path, text edit.
Ctrl+F: Open Search Panel. Cmd+F for Mac.
Ctrl+P: Open Print Panel. Cmd+P for Mac.
Ctrl+RightArrow: Open Left Navigation Panel. Cmd+RightArrow for Mac.
Ctrl+LeftArrow: Close Left Navigation Panel. Cmd+LeftArrow for Mac.
Ctrl+C: Copy annotation(path, text edit,image). Cmd+C for Mac.
Ctrl+X: Cut annotation(text). Cmd+X for Mac.
Ctrl+V: Paste annotation(path, text edit,image). Cmd+V for Mac.
.

Parameters
shortcutstring - A keyboard shortcut key.
handlerFunction|object - If it is a function, it will be called on keyup. If it is an object, it should have the format of { keydown: func1, keyup: func2 } or { keydown|keyup: func }.
[preventDefaultImplementation]boolean - If true, prevent default implementation. The default is false.
Since
7.4.0
function example (pdfViewer) {
// this will be called on keydown
pdfViewer.onShortcutKey('ctrl+a', e => {});
// this will be called on keyup
pdfViewer.onShortcutKey('ctrl+a', {
keyup: e => {},
});
// this will be called on keydown and keyup
pdfViewer.onShortcutKey('ctrl+a', {
keydown: e => {},
keyup: e => {},
});
// this will remove all handlers for escape
pdfViewer.onShortcutKey('escape', e => {}, true);
}
Examples:
/builds/foxit/phantom/cloud/phantompdf_online/foxitwebsdk/doxygen/workspace/headerfiles/uix-addons/thumbnail/thumbUIComponent.js.

◆ openPDFByFile()

PDFViewer::openPDFByFile (   file,
  options = {},
  pdfEngine = this.pdfEngine 
)
inline

Open the local document.

Parameters
fileFile|Blob|ArrayBuffer|TypedArray|DataView - File stream of PDF document.
type advantage disadvantage
File balance memory and speed. /
Blob balance memory and speed /
ArrayBuffer fast large memory usage
[options={fileName:''}]object
[options.isRenderOnDocLoaded=true]boolean - Whether to render the document once it has been loaded.
[options.beforeRenderPDFDoc](pdfDoc:PDFDoc)=>Promise<void> - A callback function used to load/import data before render PDF file. If this option is passed, the isRenderOnDocLoaded will be ignored. The default value is this.customs.beforeRenderPDFDoc.
[options.password]string - Document password.
[options.encryptPassword]string - The document's password is encrypted again. You can refer to the logic of path 'server/encrypt-password' to get your encryptPassword [Not support in Server]
[options.fileName='']string - The file name of the document.
[options.readBlock]number - Size of each read block. default equals options.jr.readBlock. [Not support in Server]
[options.annotsJson]Record<string, any> - Json format data for the initial annotation [Not support in Server]
[options.fdf]object - FDF file containing the initial annotation data. [Not support in Server]
[options.fdf.file]File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream for the initial annotation.
[options.fdf.type]number - Specify data type which will be imported: 1 for form data, 2 for annotations.
[options.drm]object - When this value is set, the DRM decryption process is invoked. [Not support in Server]
[options.drm.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.drm.subFilter]string - The sub filter of PDF document.
[options.drm.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.drm.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.drm.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.drm.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.drm.fileId]string - The file identity string.
[options.drm.initialKey]string - The user specified initial key for encryption.
[options.fileOpen]object - When this value is set, the fileOpen decryption process is invoked. [Not Support in Server]
[options.fileOpen.encryptKey]string[] - Decrypt an array of charcodes for the key
[options.fileOpen.cipher]Cipher_Type[] - The cipher type. Default: Cipher_Type::cipherRC4 , Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type.cipherNone
[options.jwt]Function - Invalid parameter Must be filled when JWT calibration is enabled. [Server Only]
Returns
Promise<PDFDoc> - this is promise. reject: {error:number, pdfDoc: pdfDoc, encryptDict: object}
error=3 wrong password error=11 security handler error

◆ openPDFByHttpRangeRequest()

PDFViewer::openPDFByHttpRangeRequest (   request,
  options = {fileName:''},
  pdfEngine = this.pdfEngine 
)
inline

Open either a URL document by HTTP range requests or an entire file depending on if the server enables range request or not.

Parameters
requestobject
request.rangeobject - HTTP range requests, responseType = 'arraybuffer'
request.range.urlstring - Request the url of the file. The second parameter to XMLHttpRequest.open, default request.range.url, this URL is relative to the path of your HTML page.
[request.range.type='GET']number - The first parameter to XMLHttpRequest.open, default GET
[request.range.user]number - The fourth parameter to XMLHttpRequest.open
[request.range.password]number - The fifth parameter to XMLHttpRequest.open
[request.range.headers]object - Set the request header for XMLHttpRequest. eg: XMLHttpRequest.setRequestHeader(x, request.header.headers.x)
[request.range.chunkSize=131072]number - Size of each Range sharding request. default 131072 = 128 *1024 = 128KB [Not support in Server]
[request.range.extendOptions]string - Set the response header to get additional options [Not support in Server]
[request.size]number - the size of the document [Not support in Server]
[options={fileName:''}]object
[options.isRenderOnDocLoaded=true]boolean - Whether to render the document once it has been loaded.
[options.beforeRenderPDFDoc](pdfDoc:PDFDoc)=>Promise<void> - A callback function used to load/import data before render PDF file. If this option is passed, the isRenderOnDocLoaded will be ignored. The default value is this.customs.beforeRenderPDFDoc
[options.password]string - document password
[options.encryptPassword]string - The document's password is encrypted again. You can refer to the logic of path 'server/encrypt-password' to get your encryptPassword. [Not support in Server]
[options.fileName='']string - document filename
[options.readBlock]number - Size of each read block. default equals options.jr.readBlock. [Not support in Server]
[options.annotsJson]object - Json format data for the initial annotation [Not support in Server]
[options.fdf]object - FDF file containing the initial annotation data. [Not support in Server]
[options.fdf.file]File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream for the initial annotation.
[options.fdf.type]number - Specify data type which will be imported: 1 for form data, 2 for annotations.
[options.drm]object - When this value is set, the DRM decryption process is invoked. [Not support in Server]
[options.drm.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.drm.subFilter]string - The sub filter of PDF document.
[options.drm.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.drm.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.drm.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.drm.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.drm.fileId]string - The file identity string.
[options.drm.initialKey]string - The user specified initial key for encryption.
[options.fileOpen]object - When this value is set, the fileOpen decryption process is invoked. [Not support in Server]
[options.fileOpen.encryptKey]number[] - Decrypt an array of charcodes for the key
[options.fileOpen.cipher]string[] - The cipher type. Default: Cipher_Type::cipherRC4 , Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type.cipherNone
[options.jwt]Function - Invalid parameter Must be filled when JWT calibration is enabled. [Server Only]
Returns
Promise<PDFDoc> - this is promise. reject: {error:number, pdfDoc: pdfDoc, encryptDict: object}
error=3 wrong password error=11 security handler error
function example (pdfViewer) {
pdfViewer.openPDFByHttpRangeRequest({
range: {
url: 'http://10.103.4.154:9898/_testfile/big/performance-diffSize/Test_1GB.pdf',
chunkSize: 10 * 1024 * 1024
}
});
}
function example (pdfViewer) {
// response header include:
// Fv-Extend-Open-Header: eyJwYXNzd29yZCI6Im93bmVyIn0=
// 'eyJwYXNzd29yZCI6Im93bmVyIn0=' equals btoa(JSON.stringify({password:'owner'}))
// So the target options value is {fileName: 'fileName.pdf', password: 'owner'}
// To get the target options
// Object.assign({},JSON.parse(atob(xmlHttp.getResponseHeader(range.extendOptions)),options}
pdfViewer.openPDFByHttpRangeRequest({
range: {
url: 'http://10.103.4.154:9898/_testfile/big/performance-diffSize/Test_1GB.pdf',
extendOptions: 'Fv-Extend-Open-Header'
}
}, {fileName: 'fileName.pdf'});
}

◆ openPDFById()

PDFViewer::openPDFById (   id,
  options = {fileName:''} 
)
inline

Open a document that exists on the server [Server Only].

Parameters
idstring - The document ID stored by the server
options={fileName:''}object
[options.isRenderOnDocLoaded=true]boolean - Whether to render the document once it has been loaded.
[options.password]string - document password
[options.fileName='']string - document filename
[options.jwt]Function - Invalid parameter Must be filled when JWT calibration is enabled. [Server Only]
Returns
Promise<PDFDoc> - this is promise. reject: {error:number, pdfDoc: pdfDoc, encryptDict: object}
error=3 wrong password error=11 security handler error

◆ pasteAnnots()

PDFViewer::pasteAnnots (   datas)
inline

Paste annotations into the lower right corner of the center.

Note
Not support strikeout, highlight, squiggly, underline, redact, caret, screen, sound, popup annotations, and signature field.
Parameters
datasobject[] - Annots information.
See also
copyAnnots
Returns
Promise<Array<Annot>> - An Annot array of new pasted annotations.
Since
8.3
async function example(pdfViewer){
const data = [{
id: 12006,
pageIndex: 0,
rect: {
left: 346.07672119140625,
bottom: 725.1610717773438,
right: 392.5015869140625,
top: 763.5979614257812},
type: "square"
}];
await pdfViewer.pasteAnnots(data);
}

◆ print()

PDFViewer::print (   { isPortfolio, rangeType, pages=[], printType=['page'], progress, printer, showHeaderFooter=this.getPrintSetting('showHeaderFooter'), quality=this.getPrintSetting('quality')||100, },
  callback = noop 
)
inline

Prints the current document with specified options. Example:

pdfViewer.print({
pages: [0, 1],
printType: ['page', 'annot'],
quality: 100,
showHeaderFooter: false
}, function(message) {
switch(message.state) {
case 'start':
console.log('Start generating page images')
break;
case 'progress':
console.log('Page image URI has been generated', message.pageIndex, message.imageURI, message.total)
break;
case 'end':
console.log('Finish generating page images')
break;
}
})

.

Note
Prints a document with a high quality (larger than 300%) may result in browser memory consumptions.
Parameters
optionsobject
options.pagesArray<number | { pageIndex: number; rect?: { x: number; y: number; width: number; height: number } }> - If the type is number, will be printed specified pages by parameter. If the parameter type is object and the rect attribute isn't empty, print the specified area on page, else rect attribute is empty, same as parameter type is number.
options.printTypestring[] - Represents the content type to print. It includes "page" and "annot". The default one is "page"
options.progressProgressComponent | boolean - Represents the print progress bar. True is the default value which means to show the progress bar. False is the opposite. To customize the progress bar UI, you can pass a custom ProgressComponent object.
options.qualitynumber - Represents the print quality which is calculated in percentage. The valid range is 100~1000.
options.showHeaderFooterboolean - Represents to show or hide the Header&Footer. True is the default value which means to print with header & footer. False means the opposite. This option is only available on Chrome, FireFox and Chromium Edge.
callback(data: {state: 'start'} | {state: 'progress', pageIndex:number, total:number, imageURI:string} | {state: 'end', result:{[pageIndex:number]:string}})=>void - This callback will be triggered when the print state got changed!
Returns
Promise<void>
See also
setDefaultPrintSetting
Since
7.6.0

◆ printCurrentView()

PDFViewer::printCurrentView ( )
inline

print the currently displayed screen content. Note: If the printed content is spread across pages, calling this interface can't print any content.

Returns
Promise<void>
Since
8.1.0

◆ printEx()

PDFViewer::printEx (   {type, pageRange, progress},
  callback = noop 
)
inline

Prints the current document with specified options. Example:

pdfViewer.printEx({
type: 0,
pageRange: "1,2,5-8",
})

.

Parameters
optionsobject
options.typenumber - Represents the content type to print. 0: print document 1: print document and markups 2: print document and stamps 3: print form fields only
options.pageRangestring - Print the pages by the specified page numbers. such as: "1,2,5-8", include the page number 8
options.progressProgressComponent | boolean - Represents the print progress bar. True is the default value which means to show the progress bar. False is the opposite. To customize the progress bar UI, you can pass a custom ProgressComponent object.
callback(data: {state: 'start'} | {state: 'progress', progress: number} | {state: 'end'})=>void - This callback will be triggered when the print state got changed!
Returns
Promise<void>
Since
8.4.0

◆ redraw()

PDFViewer::redraw (   force)
inline

Redraw the currently visible page(s).

Parameters
[force=false]boolean - true: This will also refresh the cache.
Returns
Promise<void>

◆ registerMultimediaPlayers()

PDFViewer::registerMultimediaPlayers (   multimediaPlayers)
inline

Register the multimedia players.

Parameters
multimediaPlayersArray<MultimediaPlayer> - The custom multimedia players.
Returns
void
Since
10.0.0

◆ registerPrintHandler()

PDFViewer::registerPrintHandler (   handler)
inline

Register print handler.

Note
Print handler is called and overrides the default print behavior in the following cases:
1. Action: Click print popup box OK button on the UI
2. PDFViewer.printEx
Parameters
handlerRegisterPrintHandlerCallback - Print handler.
Example
pdfViewer.registerPrintHandler(function (options) {
// Your custom print logic.
});
Since
9.1.0

◆ registerProgressHandler()

PDFViewer::registerProgressHandler (   callback)
inline

Register a progress handler.

Note
The default progress component will display when the following methods are called:
1. PDFDoc.sign
2. PDFDoc.addWatermark
3. PDFDoc.addAnnots
4. Action: Run Form Recognition on the UI
5. PDFViewer.print: when no custom progress is provided
6. PDFViewer.printEx: when no custom progress is provided
Parameters
callback(taskType,progress,status)=>void
callback.taskTypestring - The task type.
callback.progressnumber|Object - This parameter can be either a number or an object. If it is a number, it represents the overall progress of the task as a percentage. If it is an object, it has two properties: current and total, which represent the current progress and total progress of the task, respectively.
callback.progress.currentnumber - This property represents the current progress of the task.
callback.progress.totalnumber - This property represents the total progress of the task.
callback.statusstring - This parameter indicates the current status of the task progress.
It should be one of the values defined in the PROGRESS_STATUS constant.
Since
9.1.0
Example:
function example(pdfViewer){
return pdfViewer.registerProgressHandler((taskType,progress,status)=>{
//do something
})
}

◆ registerSignatureHandler()

PDFViewer::registerSignatureHandler (   filter,
  subfilter,
  handler 
)
inline

Register a signature handler. [Not support in Server]

Parameters
filterstring - Filter of signature handler.
subfilterstring - Subfilter of signature handler.
handlerobject - An object specify http api to sign and verify signatures.
[handler.sign]string - An object specify server api to sign and verify signatures.
[handler.verify]string - An object specify server api to sign and verify signatures.
Returns
void -
Since
7.3.0
Deprecated:

◆ removeAnnotationIcon()

PDFViewer::removeAnnotationIcon (   type,
  category,
  name 
)
inline

Remove an custom annotation's icon. [Not support in Server]

Parameters
typestring - The annotation's icon type. Currently only 'stamp' is available.
categorystring - The category's icon. If null, all icons will be removed.
namestring - The icon's name. If null, all icons in specified category will be removed.
Since
7.4.0
Returns
Promise<void>

◆ renderDoc()

PDFViewer::renderDoc (   pdfDoc,
  scale = this.config.defaultScale 
)
inline

Render a loaded PDF document.

Since
7.4.0
Parameters
pdfDocPDFDoc - The PDF document object, which is returned by open functions such as openPDFByFile and openPDFById etc.
scalenumber|string - The multiple of the default display. String enum:fitWidth and fitHeight.
Returns
Promise<boolean> - Return true indicating successful document rendering, false otherwise. reject: {error:number}
error=-3 An unknown error

◆ reopenPDFDoc()

PDFViewer::reopenPDFDoc (   pdfDoc,
  options = {} 
)
inline

When a document fails to open, you can call this method and reproduce the passing parameters to reopen the file that failed to open.

Parameters
pdfDocPDFDoc
[options]object
[options.isRenderOnDocLoaded=true]boolean - Whether to render the document once it has been loaded.
[options.beforeRenderPDFDoc](pdfDoc:PDFDoc)=>Promise<void> - A callback function used to load/import data before render PDF file. If this option is passed, the isRenderOnDocLoaded will be ignored. The default value is this.customs.beforeRenderPDFDoc
[options.password]string - document password
[options.encryptPassword]string - The document's password is encrypted again. You can refer to the logic of path 'server/encrypt-password' to get your encryptPassword [Not Support in Server]
[options.fileName='']string - document filename
[options.annotsJson]object - Json format data for the initial annotation [Not Support in Server]
[options.fdf]object - Json format data for the initial annotation [No Support in Server]
[options.fdf.file]File|Blob|ArrayBuffer|TypedArray|DataView - Specify fdf file's stream for the initial annotation.
[options.fdf.type]number - Specify data type which will be imported: 1 for form data, 2 for annotations.
[options.jwt]Function - Invalid parameter Must be filled when JWT calibration is enabled. [Server Only]
[options.drm]object - When this value is set, the DRM decryption process is invoked. [Not Support in Server]
[options.drm.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.drm.subFilter]string - The sub filter of PDF document.
[options.drm.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.drm.keyLength]number - The key length, in bytes.
For SecurityConstsPDF::cipherRC4 cipher, this value should be between 5 and 16.
For SecurityConstsPDF::cipherAES cipher, this value should be 16 or 32.
[options.drm.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.drm.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.drm.fileId]string - The file identity string.
[options.drm.initialKey]string - The user specified initial key for encryption.
[options.fileOpen]object - When this value is set, the fileOpen decryption process is invoked. [Not Support in Server]
[options.fileOpen.encryptKey]number[] - Decrypt an array of charcodes for the key
[options.fileOpen.cipher]string[] - The cipher type. Default: Cipher_Type::cipherRC4 , Please refer to values starting from Cipher_Type::cipherRC4 and this should be one of these values except Cipher_Type.cipherNone
Returns
Promise<PDFDoc> - reject: {error:number, pdfDoc: pdfDoc, encryptDict: object}
error=3 wrong password error=11 security handler error

◆ rotateTo()

PDFViewer::rotateTo (   degree,
  options 
)
inline

Rotates the current document to the specified degree. This method only changes the rendering of the view and does not change the PDF document data.

Since
7.4.0
Parameters
degreenumber - The rotation degree value, It should be 0,90,180, 270, or any angle value that is a multiple of 90 degrees.
[options]object - Rotated center point information (added in version 9.0.0), including page index and device coordinates relative to the top-left corner of the page. The default is the top left corner of the current page
options.pageIndexnumber - The index of the page where the rotation center point is located. After rotation, It will be displayed as the current page.
options.offsetXnumber - The X-axis offset in the upper-left corner of the page. If you need to use PDF coordinates, you can use this API(PDFPageRender.transformPoint) for conversion.
options.offsetYnumber - The Y-axis offset in the upper-left corner of the page. This coordinate is relative to the top left corner of the page. If you need to use PDF coordinates, you can use this API(PDFPageRender.transformPoint) for conversion.
Returns
Promise<void> - A rejected promise means any failure, while a fulfilled promise means success!
See also
PDFViewer::getRotation

◆ setActionCallback()

PDFViewer::setActionCallback (   ActionCallbackClass)
inline

Set an ActionCallback class to Web SDK, in aid of performing PDF actions. User should implement a class and call this function to set the action callback to Web SDK.

Parameters
ActionCallbackClassnew(app:any)=>ActionCallback - A customized ActionCallback class. null/undefined means not use any action callback. Users can implement only part of the callbacks according to actual requirements. The custom ActionCallback class will be instantiated internally and will receive an app object for easy invocation of the internal implementation.
Since
7.6.0

◆ setAutoCalculateFieldsFlag()

PDFViewer::setAutoCalculateFieldsFlag (   autoCalculate)
inline

Provide API to set Automatically Calculate Field Values.

Parameters
autoCalculateboolean - Specifies whether to set automatically calculate field values.
Since
7.5.0
function example (pdfViewer) {
pdfViewer.setAutoCalculateFieldsFlag(false)
}

◆ setDefaultAnnotConfig()

PDFViewer::setDefaultAnnotConfig (   fn)
inline

Set the default configured callback function for the annotation.See PDFPage::addAnnot for the return object format.

Parameters
fn(type:string,intent:string)=>object - The default configured callback function.
function example (pdfViewer) {
pdfViewer.setDefaultAnnotConfig(function(type,intent){
let config={};
config.borderInfo = {};
config.defaultAppearance = {};
switch (type) {
case "underline":
config.color=0xff0000;
break;
case "squiggly":
config.color=0xff0000;
break;
default:
config.calloutLineEndingStyle = 2;//Circle
config.startStyle = 1;//square
config.endStyle = 1;//square
config.fillColor = 0xffff00;
config.title = 'title';
break;
}
return config;
});
}

◆ setDefaultPrintSetting()

PDFViewer::setDefaultPrintSetting (   printSetting)
inline

Configures printing parameters.

Note
Printing document with high quality(large than 300%) may crash on non-modern browser such as IE11.
Parameters
[printSetting={}]object - Specifies print setting.
[printSetting.showHeaderFooter=false]boolean - Sets whether to print the current document with the Header&Footer or not. False means to print without Header&Footer, otherwise is true. This option is only available on Chrome, FireFox and Chromium Edge.
[printSetting.quality=100]number - Specifies the printing quality percentage. Valid range: 100 ~ 1000.
Since
7.4.0

◆ setDocReadColors()

PDFViewer::setDocReadColors (   colors)
inline

Sets the background and foreground colors for viewing documents. [Not support in Server]

Parameters
colorsobject - The object includes the background and foreground.
Since
7.4.0
function example (pdfViewer) {
pdfViewer.setDocReadColors({
background: 0xffff0000,
foreground: 0xff0000ff,
});
}

◆ setEnableJS()

PDFViewer::setEnableJS (   enable)
inline

Set whether JavaScript is allowed or not.

Parameters
enableboolean - True allows JavaScript to execute, and false does the opposite

◆ setEnableLoad3DModule()

PDFViewer::setEnableLoad3DModule (   enable)
inline

Set whether the 3D module is enabled to be loaded.

Parameters
enableboolean - True to enable to load the 3D module. False to disable to load the 3D module.
Since
10.0.0

◆ setEnableShortcutKey()

PDFViewer::setEnableShortcutKey (   enable)
inline

Set whether shortcut key is enabled or disabled.

Parameters
enableboolean - True to enable shortcut key. False to disable shortcut key.
Since
7.4.0

◆ setEraserSize()

PDFViewer::setEraserSize (   width)
inline

Sets the width of the eraser.

Parameters
widthnumber - The width of the eraser.
Since
7.6.0

◆ setFormatOfDynamicStamp()

PDFViewer::setFormatOfDynamicStamp (   sperator,
  timeFormat 
)
inline

Set dynamic information of stamps. [Not support in Server]

Parameters
speratorstring - Seperator character between user name and time.
timeFormatstring - Time format same as parameter of Date.Format.
Since
7.4.0

◆ setFormCreationContinuously()

PDFViewer::setFormCreationContinuously (   isContinuous)
inline

Sets whether to keep the current form field to be created continuously.

Parameters
isContinuousboolean - Specifies whether to keep the current form field. True to stick to the current form field. False to exit the current form field.
function example (pdfViewer) {
pdfViewer.setFormCreationContinuously(false);
}

◆ setFormFieldFocusRectangleVisible()

PDFViewer::setFormFieldFocusRectangleVisible (   isVisible)
inline

Set whether form field focus rectangle is visible or not.

Parameters
isVisibleboolean - Specifies whether to show form field focus rectangle.
Since
7.6.0

◆ setFormHighlightColor()

PDFViewer::setFormHighlightColor (   color,
  requiredColor 
)
inline

Set form highlight color. [Not support in Server]

Parameters
colornumber - Specify highlight color. Format: 0xAARRGGBB.
[requiredColor]number - Specify highlight color for the required field. Format: 0xAARRGGBB.
Since
7.4.0
function example (pdfViewer) {
pdfViewer.setFormHighlightColor(0x808080FF);
}

◆ setInkSignList()

PDFViewer::setInkSignList (   inkSignList)
inline

Set ink signature list.

Parameters
inkSignListobject[] - An array of ink signature.
Since
7.4.0
function example (pdfViewer) {
pdfViewer.setInkSignList([{
dataURL: 'data:image/png;base64,iVBOR...', // The base64 string.
}]);
}

◆ setJRFontMap()

PDFViewer::setJRFontMap (   fontMaps)
inline

Set JR custom font. [Not support in Server]

Parameters
fontMapsFontMap[] - Custom fonts. The Settings are valid before opening the document.
See also
The charsets of the font. Please refer to Font_Charset or Font_CIDCharset .
Since
7.2.0
function example (pdfViewer) {
pdfViewer.setJRFontMap([{
nameMatches: [
// A string or regular expression that matches a literal name. Can be an empty array or unset.
/(helvetica)|(helveticabold)|(helveticaoblique)/,
],
glyphs: [
{
bold: 0x1f0, // 0b111110000 match 500,600,700,800,900 weight font
flags: 0x80000, // Font Descriptor Flags
url: 'NotoSans-Bold.ttf.brotli',
isBrotli: true,
},
{
bold: -1, // Matches any word width
flags: 0x80000,
url: 'NotoSans-Regular.ttf'
},
],
charsets:[0], //The charsets of the font.
}])
}

◆ setPencilDrawingTimeOut()

PDFViewer::setPencilDrawingTimeOut (   millseconds)
inline

Sets the timeout for the pencil drawing. A new pencil is created beyond the timeout period.

Parameters
millsecondsnumber - The timeout period, millseconds.
Note
It takes effect next time CreatePencilStateHandler activacted.
Since
7.4.0

◆ setSnapMode()

PDFViewer::setSnapMode (   stateHandlerName,
  mode 
)
inline

Set the snap mode that will be used to calculate the point position.

Parameters
stateHandlerNamestring - State handler name which supports snap mode:
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_LINE
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_ARROW
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_DISTANCE
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_PERIMETER
  • PDFViewCtrl.constants.STATE_HANDLER_NAMES.STATE_HANDLER_CREATE_AREA
modeSNAP_MODE - PDFViewCtrl.constants.SNAP_MODE[]
Returns
void
See also
PDFViewCtrl.constants.ViewerEvents.snapModeChanged
Since
7.6.0

◆ setUserName()

PDFViewer::setUserName (   userName,
  pdfEngine = this.pdfEngine 
)
inline

Set the global username.

Parameters
userNamestring - Set the global username that will be used for the annotation title
Returns
Promise<void>

◆ takeSnapshot()

PDFViewer::takeSnapshot (   pageIndex,
  left,
  top,
  width,
  height 
)
inline

Capture the picture of the specified area on the page.

Parameters
pageIndexnumber - index of the page
leftnumber - The X-axis offset in the upper-left corner of the page in device pixels.
topnumber - The Y-axis offset in the upper-left corner of the page in device pixels.
widthnumber - Area width in device pixels.
heightnumber - Area width in device pixels.
See also
PDFPage.getDevicePoint
Returns
Promise<Blob> - image blob data
Since
8.2.0

◆ uploadImage()

PDFViewer::uploadImage (   blob)
inline

Upload image blob data to the snapshot server, and then returns a same-origin image URL, which can be used to break some browser's limitations.

Parameters
blobBlob - image data
Returns
Promise<string> - image URL

◆ zoomAtPosition()

PDFViewer::zoomAtPosition (   scale,
  fixedPosition 
)
inline

Scale the page with the point of the fixedPosition as the center.

Parameters
scalenumber - The scaling ratio, which must be within the minScale and maxScale ranges specified in the PDFViewer.constructor parameters.
fixedPositionobject - The point where the fixed point is located, relative to upper left of the viewport.
[fixedPosition.pageIndex]number - The page index is where the fixed point is located. The pageIndex and fixedPosition will be ignored if the fixedPosition point is out of the PDF Page boundary.
fixedPosition.xnumber - The x-axis coordinate value, that is relative to left-corner of the browser viewport
fixedPosition.ynumber - The y-axis coordinate value, that is relative to upper-corner of the browser viewport
Returns
Promise<void>
Since
8.5.0
Note
The zoomAtPosition function is implemented by encapsulating the zoomTo interface. Its parameter fixedPosition represents a point on the page that can remain in a fixed position when zooming, such as the coordinate point when zooming with the mouse scroll wheel, or when double-clicking the page.The zoomTo function also accepts the coordinates of the input position, but its point is located in the upper-left corner of the visible page area after zooming, which requires a lot of calculation to achieve the zoom effect of the mouse scroll wheel and double click.
To avoid rendering conflicts, please use the throttle function to control the interval between calls when this method is called consecutively (e.g. in the mousewheel event) to ensure the rendering effect

◆ zoomTo()

PDFViewer::zoomTo (   scale,
  position 
)
inline

Zoom to the given scale.

Parameters
scalenumber|'fitWidth'|'fitHeight' - The values must be within the minScale and maxScale ranges specified in the PDFViewer.constructor parameters.
If it's a string, only 'fitWidth' and 'fitHeight' are valid. The value 'fitHeight' is consistent with the function 'Fit Page'.
[position]object - A position that is the center point for zoom.
position.pageIndexnumber - Page index of target page.
position.xnumber - The x-axis of target position in PDF coordinate system.
position.ynumber - The y-axis of target position in PDF coordinate system.
Returns
Promise<void>

Member Data Documentation

◆ element

HTMLElement element

A DOM element used to render the stuffs generated in PDFViewer. This element is the DOM node passed by PDFViewer.init method.

See also
PDFViewer.init
Since
7.6.0

◆ i18n

typeof i18next PDFViewer::i18n

I18next instance.

See also
https://www.i18next.com/overview/api
PDFViewer.constructor
Since
8.5.0

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