FoxitPDFSDKforWeb
8.4.0
Foxit PDF SDK for Web
|
Public Member Functions | |
addUIEventListener (type, listener) | |
Attach an event listener to PDFUI instance by type. More... | |
addViewerEventListener (type, listener) | |
Attach an event listener to PDFViewer instance by type. More... | |
callAddonAPI (addonLibrary, action, args=[]) | |
Trigger an action to specified Addon. More... | |
changeLanguage (language) | |
Switch UI language. More... | |
constructor (PDFUIOptions) | |
Constructs a PDFUI instance. More... | |
destroy () | |
Destroys a PDFUI instance. The opening document will be closed and all component DOM elements will be destroyed. More... | |
getAllComponentsByName (name) | |
Get all components which name is the specific string. More... | |
getAnnotationIcons (annotType, onlyCustomized) | |
Get Customized icons. More... | |
getComponentByName (name) | |
Get the first component which name is the specific string. More... | |
getPDFViewer () | |
Get the PDFViewer instance asynchrounously. More... | |
getRootComponent () | |
Obtains the root component instance. More... | |
getSelectedTextInfo () | |
Gets the currently selected text information, including the text boundary rectangle in point unit based on the PDF page coordinates, the PDFPage instances and text content. If there's no text is selected, this method returns a none value promise instance. The PDF point unit of the rectangle can be converted to device pixels, as shown in the following example: pdfui.getSelectedTextInfo() .then(info => { if(!info) { return; } return pdfui.getPDFViewer().then(viewer => { const pdfPage = info.page; const pageIndex = pdfPage.getIndex(); const pageRender = viewer.getPDFPageRender(pageIndex); const pageScale = pageRender.scale; return info.rectArray.map(rect => pdfPage.getDeviceRect(rect, scale)) }); }) .then(rectArrayInPixelUnit => { // to do sth. }); . More... | |
loading (coverOn=document.body, text='', animation=true) | |
Overlays a loading modal layer on a specified element. More... | |
openFormPropertyBoxAfterCreated (isOpen) | |
Set whether the properties box is displayed when creating a form field. More... | |
registerSignatureFlowHandler (handler) | |
Register the signature flow handler. More... | |
registerSignaturePropertyHandler (handler) | |
Register the signed properties dialog handler . More... | |
registerSignHandler (handler) | |
Register signing handler. More... | |
removeUIEventListener (type, listener) | |
Detach event listener from PDFUI instance by type and its callback function. More... | |
removeViewerEventListener (type, listener) | |
Detach event listener from PDFViewer instance by type and its callback function. More... | |
setDefaultMeasurementRatio ({ userSpaceScaleValue=1, userSpaceUnit='inch', realScaleValue=1, realUnit='inch' }={}) | |
Set the default scale ratio for measuring. More... | |
setVerifyHandler (handler) | |
Register signature verifying handler. More... | |
waitForInitialization () | |
A method returns a Promise instance that will be fullfilled after PDFUI completes initialization. More... | |
![]() | |
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... | |
close (before=this.customs.closeDocBefore, after=this.customs.closeDocAfter) | |
Close the open document. More... | |
collaborate (action, data) | |
Sends collaboration data to another clients in same share id. The data parameter can be passed an asynchorounous callback function, so that data will be generated only when the collaboration is enabled, which is beneficial to the performance when the collaboration is not enabled. More... | |
constructor ({ preloadJR=true, preloadSR=false, libPath, jr, sr, i18n, i18nOptions, eventEmitter=new EventEmitter(), minScale=0.01, maxScale=25, defaultScale='fitWidth', scaleFrequency=0, tileSize=1200, tileCache=true, 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, engineMode=JR, sharedWorker=false, noJSFrame=false, showCommentList=false, showAnnotTooltip=false, showFormFieldTooltip=false, viewerUI, applicationContext, instanceId=PDF_VIEWER_INSTANCE_ID_SEQUENCE===0 ? '' :'pdf_viewer_'+(PDF_VIEWER_INSTANCE_ID_SEQUENCE++) }={}) | |
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... | |
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... | |
getCurrentPDFDoc () | |
Get current pdf doc object. 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 () | |
Get ink signature list. 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... | |
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... | |
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... | |
openFileByShareId (shareId) | |
After obtains the collaborative link, the share id can be parsed to open the file that shared from other client. 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=this.printProgress, 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=this.printProgress}, 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... | |
registerCollabDataHandler (action, handler) | |
registerSignatureHandler (filter, subfilter, handler) | |
Register a signature handler. [Not support in Server] More... | |
removeAnnotationIcon (type, category, name) | |
Remove an 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) | |
Rotate the current document to specified degree. This method only changes the rendering effect 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... | |
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... | |
zoomTo (scale, position) | |
Zoom to the given scale. More... | |
Static Public Member Functions | |
static | module (name, deps) |
alias of Modular.module More... | |
Additional Inherited Members | |
![]() | |
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... | |
|
inline |
Attach an event listener to PDFUI instance by type.
type | {string|string[]|{[string]:Function}} - the event type, all event types are defined in UIExtension::UIEvents. |
listener | {Function} - the event callback function |
|
inline |
Attach an event listener to PDFViewer instance by type.
type | {string|string[]|{[string]:Function}} - the event type, all event types defined in UIExtension::PDFViewCtrl::Events. |
listener | [Function] - (Optional if type is a map objct)The event callback function. |
|
inline |
Trigger an action to specified Addon.
addonLibrary | string - refer to the 'library' property defined in addon.info.json file of the addon |
action | string - action name |
args | any[] |
addonLibrary | action | args | returns | description | example |
---|---|---|---|---|---|
UndoRedoAddon | undo | - | Promise<void> | Undo last operation that support undo/redo. | pdfui.callAddonAPI("UndoRedoAddon","undo") |
redo | - | Promise<void> | Redo the last undone operation. | pdfui.callAddonAPI("UndoRedoAddon","redo") | |
undoAll | - | Promise<void> | Undo all operations that support undo/redo | pdfui.callAddonAPI("UndoRedoAddon","undoAll") | |
PrintUIXAddon | showPrintDialog | - | Promise<void> | Display the print dialog. | pdfui.callAddonAPI("PrintUIXAddon","showPrintDialog") |
ReadAloudAddon | onActivationChange | (isActivated: boolean) => void | Promise<() => void> - Returns a function to unregister events. | Register events to listen for read-aloud activation | pdfui.callAddonAPI( "ReadAloudAddon", 'onActivationChange', [function(isActivated) { console.info(isActivated ? 'read aloud is activated' : 'read aloud is deactivated'); }] ) |
Thumbnail | zoomTo | number | Promise<boolean> - Boolean value to indicate success or not | Zooming thumbnail of the sidebar. The valid zoomScale value should be between 0 and 10. | pdfui.callAddonAPI('Thumbnail', 'zoomTo', [0.96]) |
Thumbnail | getZoomScale | - | Promise<number> - Current zoom scale value. | Obtains the thumbnail zoom scale value. | pdfui.callAddonAPI('Thumbnail', 'getZoomScale') .then(zoomScale => { console.log('current zoom scale is', zoomScale); }) |
Thumbnail | onSelectThumbnail | (selectedPageIndexes: number[], lastSelectedPageIndexes: number[]) => void; | Promise<() => void> - Returns a function to unregister events. | Register events to listen for selection and de-selection of thumbnail items. | pdfui.callAddonAPI( 'Thumbnail', 'onSelectThumbnail', [(selectedPageIndexes, lastSelectedPageIndexes) => { console.log('current selected page indexes', selectedPageIndexes, 'Last selected page indexes', lastSelectedPageIndexes); }] ) |
|
inline |
Switch UI language.
language | {string} - language, en-US, zh-CN |
|
inline |
Constructs a PDFUI instance.
options | {object} - options to create PDFUI |
options.viewerOptions | {object} - The options for creating PDFViewer; |
options.renderTo | {HTMLElement|string} - Specifies a target to mount this PDFUI instance, it must be an DOM element or css selector |
[options.appearance=RibbonAppearance] | {Appearance} - An appearance instance defines the layout-template, beforeMount/afterMount lifecycle and how to enable/disable components on PDF document opening/closing. Its useful for implementing scenarios that adapt to different UI layouts of different clients. [options.fragments] {object[]} - UI fragments array, defines serveral UI components and business logics. |
[options.addons] | {string|Array<string|UIXAddon>} - If string, should be the path of bundle addons' scripts. If array, it's elements should be UIX addons paths or UIXAddon classes [options.template] {string} - You should rewrite this template option if you want to custom the layout, and if your template parser is not compatible with internal template format, you must rewrite this template otherwise many unpredicatable errors will occur. This parameter is deprecated since version 7.1.1, We are sugested you to use Appearance.getLayoutTemplate now. |
[options.i18n] | {object} - The options for i18next(an internationalization-framework), for more details please visit https://www.i18next.com/overview/configuration-options |
[options.i18n.absolutePath] | {string} - The i18n resources directory, relatives to the root directory of your site. |
[options.customs] | {object} - Some customize options |
[options.customs.getLoadingMode] | {(fileOrUrl)=>number} - Callback used to specify loading mode. Please refer to Loading_Mode |
[options.customs.defaultStateHandler] | {STATE_HANDLER_NAMES} - default state handler name. |
[options.customs.handlerParams] | {object} - Parameters for state handler, see STATE_HANDLER_NAMES. |
[options.customs.defaultExportCommentsFormat] | {string} - custom default format of export comments file, it should be the one of 'xfdf', 'fdf' and 'json'; |
[options.customs.scalingValues] | {number[]} - A list of scaling values, with the default value is [0.5, 0.75, 1, 1.25, 1.5, 2, 4, 6], that has been used in marquee, loupe and zoom dropdown button in toolbar. |
[options.customs.autoDownloadAfterSign] | {boolean} - True is the default value which means download automatically after signing, otherwise not. |
[options.customs.getSignedDocument] | {(Blob)=>{}} - Get signed document. |
[options.customs.loading] | {(coverOn: HTMLElement, text: string, animation: boolean) => string | Component | HTMLElement | Promise<string | Component | HTMLElement>} - A function used to display a custom load layer. This function can return HTML or a layout template, or return component objects. |
|
inline |
Destroys a PDFUI instance. The opening document will be closed and all component DOM elements will be destroyed.
|
inline |
Get all components which name is the specific string.
name | {string} - component name. |
|
inline |
Get Customized icons.
annotType | {string} - The annotation’s icon type. Currently only ‘stamp’ is available. |
onlyCustomized | {boolean} -True is for custom stamps only. False means for all icons. |
|
inline |
Get the first component which name is the specific string.
name | {string} - component name. |
|
inline |
Get the PDFViewer instance asynchrounously.
|
inline |
Obtains the root component instance.
|
inline |
Gets the currently selected text information, including the text boundary rectangle in point unit based on the PDF page coordinates, the PDFPage instances and text content. If there's no text is selected, this method returns a none value promise instance. The PDF point unit of the rectangle can be converted to device pixels, as shown in the following example:
.
|
inline |
Overlays a loading modal layer on a specified element.
[coverOn=document.body] | {HTMLElement|Component} - overlaid element. |
[text=''] | {string} - The text is positioned below the animated image and supports i18n. |
[animation=true] | {boolean|string} - Passing boolean to show or hide the animation. Passing string to define the animation using a CSS class. |
|
inlinestatic |
|
inline |
Set whether the properties box is displayed when creating a form field.
isOpen | {Boolean} - Specifies whether to show the properties box. pdfui.openFormPropertyBoxAfterCreated(false) |
|
inline |
Register the signature flow handler.
handler | {(signField)=>Promise<setting>} - Triggered when a new unsigned field is selected. |
signField | {PDFField} - The selected unsigned field. |
setting | {object} - Specifies signature info. |
setting.filter | {string} - Filter of signing. |
setting.subfilter | {string} - Subfilter of signing |
setting.flag | {number} - The appearance flag for signing. Please refer to Signature_Ap_Flags. |
setting.signer | {string} - The signer of the signature. |
setting.reason | {string} - The reason for signing. |
setting.email | {string} - The email of the signing. |
setting.image | {string} - (e.g. BLOB URL, HTTP, HTTPS, and Base64URL)The image for singing. |
setting.distinguishName | {string} - The distinguished name of signing. |
setting.location | {string} - The location of signing. |
setting.text | {string} - The signing descriptive information. |
setting.defaultContentsLength | {number} - 7942 is the default length of signature contents, in bytes. It should not be less than 4098. |
setting.sign | {(setting,plainBuffer)=>Promise<ArrayBuffer>} - The digest and sign handler, The return value is an object with file buffer and byte range. |
|
inline |
Register the signed properties dialog handler .
handler | {(signatureInfo)=>{}} - If not passed, the default Dialog will display. |
handler.signatureInfo | {object} - Signature information. Please refer to PDFDoc::sign. As follows: { filter:{object}, subfilter:{object} , rect: {PDFRect}, pageIndex: {number}, flag: {number}, signer: {string}, reason: {string}, email: {string}, image: {string}, //such as "data:image/png;base64,....", distinguishName: {string}, location: {string}, textValue: {string}, fieldName: {string}, signTime: {number} } |
|
inline |
Register signing handler.
handler | {Object} - Signing handler. |
handler.filter | {string} - Filter of this handler. |
handler.subfilter | {string} - Subfilter of this handler. |
handler.signer | {string} - Singer name of this handler. |
handler.distinguishName | {number} - Distinguish name (DN) of signature. |
handler.location | {number} - Location of signature. |
handler.reason | {number} - Reason of signature. |
handler.defaultContentsLength | {number} - 7942 is the default length of signature contents, in bytes. It should not be less than 4098. |
handler.flag | {number} - Appearance flags of signature. Please refer to Signature_Ap_Flags. |
handler.sign | {(signInfo,plainBuffer)=>Promise<ArrayBuffer>} - Digest and sign handler. |
|
inline |
Detach event listener from PDFUI instance by type and its callback function.
type | {string|string[]} - The event type which passed as the first parameter of PDFUI::addUIEventListener(). |
listener | {Function} - The event callback function passed as the secondary parameter of PDFUI::addUIEventListener(). |
|
inline |
Detach event listener from PDFViewer instance by type and its callback function.
type | {string|string[]} - The event type which passed as the first parameter of PDFUI.addViewerEventListener(). |
listener | {Function} - The event callback function passed as the secondary parameter of PDFUI.addViewerEventListener(). |
|
inline |
Set the default scale ratio for measuring.
options | {object} - options of measurement information |
options.userSpaceScaleValue | {number} - Set the ratio value in user space. |
options.userSpaceUnit | {string} - Set the ratio unit in user space. Only 'inch,pt,cm,mm,pica' types are supported. Please refer to Annot_Unit_Type |
options.realScaleValue | {number} - Set the ratio value in real space. |
options.realUnit | {string} - Set the ratio unit in real space. Please refer to Annot_Unit_Type |
|
inline |
Register signature verifying handler.
handler | {(field,plainBuffer,signedData)=>Promise<number} - Verifying handler which will return signature's state. Please refer to Signature_State. |
|
inline |
A method returns a Promise instance that will be fullfilled after PDFUI completes initialization.