| FoxitPDFSDKforWeb v11.0.6 Archives Foxit PDF SDK for Web

Public Member Functions | Static Public Member Functions | List of all members
PDFUI Class Reference
UIExtension
Inheritance diagram for PDFUI:

## Public Member Functions
| addCssFonts (fonts=[])
| Add the custom css fonts. More...
| 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...
| getAddonInstance (addonLibrary)
| Retrieves a loaded UIExtension (UIX) addon instance by its associated library name. More...
| getAllComponentsByName (name)
| Get all components which name is the specific string. More...
async | getAnnotationIcons (annotType, onlyCustomized)
| Get Customized icons. More...
| getBookmarkUIService ()
| Obtains the BookmarkUIService instance. More...
| getComponentByName (name)
| Get the first component which name is the specific string. More...
| getCurrentLanguage ()
| Get current language. Usually the language specified in the browser settings, if not supported it defaults to 'en-US'. 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...
| getSignatureService ()
| Alias of PDFViewer.getSignatureService. Obtains the SignatureService instance for customizing signature signing/verification behavior. More...
| getSignatureWorkflowService ()
| Retrieves the instance of SignatureWorkflowService. More...
| getStampService ()
| Obtains the StampService instance. 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 (signatureHandler)
| 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...
| setSnapshotInteractionClass (interactionClass)
| Override the builtin interaction class, and customize the behavior of the snapshot tool buttons. More...
| setVerifyHandler (handler)
| Register signature verifying handler. More...
| waitForInitialization ()
| A method returns a Promise instance that will be fullfilled after PDFUI completes initialization. More...
Public Member Functions inherited from PDFViewer
| 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=true, 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, 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...
| getFormFillerService ()
| Obtains the FormFillerService instance for handling form filling operations. 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...
| getSignatureService ()
| Obtains the SignatureService instance for customizing signature signing/verification behavior. 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...
| 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...
async | pasteAnnots (datas)
| Paste annotations into the lower right corner of the center. More...
async | print ({ isPortfolio, rangeType, pages=[], printType=['page'], progress, printer=undefined, 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, reverse, 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)
| Add a function to destroyHooks list, which will be called during destroy. More...
| destroy ()
| ownsTo (owner)
| Establishes an ownership relationship where this instance will be destroyed when the owner is destroyed. Additionally, the owner will be automatically removed from the destroyHooks list when this instance is destroyed. More...

## Static Public Member Functions
static | module (name, deps)
| alias of Modular.module More...

## Additional Inherited Members
Public Attributes inherited from PDFViewer
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

PDFUI

## Member Function Documentation

## ◆ addCssFonts()

PDFUI::addCssFonts | ( |  | fonts = `[]` | ) |
| inline

Add the custom css fonts.

Note
  Only useful after defined in CSS -face rules. Such as: https://fonts.googleapis.com/css2?family=Tangerine&display=swap

See also
  https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face

Parameters

  fonts | string[] - font name {.css} @font-face { font-family: 'Tangerine'; font-style: normal; font-weight: 400; font-display: swap; src: url(https://fonts.gstatic.com/s/tangerine/v17/IurY6Y5j_oScZZow4VOxCZZM.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } {.js} function example(pdfui){ pdfui.addCssFonts(["Tangerine"]) }

Since
  8.5.0

## ◆ addUIEventListener()

PDFUI::addUIEventListener | ( |  | type,
|  |  | listener
| ) |  |
| inline

Attach an event listener to PDFUI instance by type.

Parameters

  type | string|string[]|{[type:string]:()=>void} - the event type, all event types are defined in UIExtension::UIEvents.
  listener | (...args:any[])=>void - the event callback function

Returns
  ()=>void - a function to remove this event binding.

## ◆ addViewerEventListener()

PDFUI::addViewerEventListener | ( |  | type,
|  |  | listener
| ) |  |
| inline

Attach an event listener to PDFViewer instance by type.

Parameters

  type | string|string[]|{[type:string]:()=>void} - the event type, all event types defined in ViewerEvents.
  listener | (...args:any[])=>void - (Optional if type is a map object)The event callback function.

Returns
  ()=>void - a function to remove this event binding.

Examples:
  /builds/foxit/phantom/cloud/phantompdf_online/foxitwebsdk/doxygen/workspace/headerfiles/uix-addons/thumbnail/thumbUIComponent.js.

## ◆ callAddonAPI()

PDFUI::callAddonAPI | ( |  | addonLibrary,
|  |  | action,
|  |  | args = `[]`
| ) |  |
| inline

Trigger an action to specified Addon.

Deprecated:
  Since 9.2.0, all UIXAddon APIs have been moved to the UIExtension.addons module.

Parameters

  addonLibrary | string - refer to the 'library' property defined in `addon.info.json` file of the addon
  action | string - action name
  args | any[]

Since
  7.3.0

Note

  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")
  invoke | (pdfDoc: PDFDoc|null)=>Promise<void> | Promise<void> | When using APIs such as PDFPage.addAnnot, PDFPage.removeAnnotById, PDFDoc.addAnnot, Annot.setRect to create, delete, or modify annotations inside this callback， the operation history of these actions will be automatically added to the undo stack, enabling the user to undo these actions if nedded. If no document is currently open, the callback function's pdfDoc parameter value will be null. | pdfui.callAddonAPI('UndoRedoAddon', 'invoke',[ (pdfDoc) => { const pdfPage = pdfDoc.getPageByIndex(0) return pdfPage.addAnnot({...}); } ]);
  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); }] )
  DigitalStampUIXAddon | resetIdentityInfo | - | Promise<void> | Reset identity information. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'resetIdentityInfo' )
  DigitalStampUIXAddon | setIdentityInfo | { "surname": "","name": "","title": "","associationName": "","organizationName": ""}- The identity info. | Promise<void> | Set identity information. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'setIdentityInfo',[{ "surname": "","name": "","title": "","associationName": "","organizationName": ""}] )
  DigitalStampUIXAddon | getIdentityInfo | - | Promise<{ "surname": "","name": "","title": "","associationName": "","organizationName": ""}>- The identity info. | Get identity information. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'getIdentityInfo' ) .then(info=>console.log(info))
  DigitalStampUIXAddon | setDigitalStampTemplates | templates - The custom stamp templates. [ { pdfPath:'***.pdf', // The template in PDF format which has at least one special name text field, as follows: surname, name, title, date, associationName, organizationName. name:'custom', //The name of the template. width: 50, //The width of the stamp. height: 50, //The height of the stamp } ... ] | Promise<void>. | Set custom stamp templates. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'setDigitalStampTemplates',[ [ { pdfPath:'***.pdf', // The template in PDF format which has at least one special name text field, as follows: surname, name, title, date, associationName, organizationName. name:'custom', //The name of the template. width: 50, //The width of the stamp. height: 50, //The height of the stamp } ... ] ] )
  DigitalStampUIXAddon | removeDigitalStampTemplates | names - The custom stamp template names. | Promise<void> | Remove custom stamp templates. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'removeDigitalStampTemplates' ,[ ['custom'] ] )
  DigitalStampUIXAddon | getDigitalStampTemplate | - | Promise<templates > - The custom stamp templates. Please refer to the parameters of setDigitalStampTemplates. | Get custom stamp templates. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'getDigitalStampTemplate' ) .then(info=>console.log(info))
  DigitalStampUIXAddon | setTimeFormatOfDigitalStamp | timeFormat {string} - Time format same as parameter of Date.Format. | Promise<void> | Set time format of digital stamps. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'setTimeFormatOfDigitalStamp',['YYYY/MM'])
  DigitalStampUIXAddon | setDefaultSize | size {object} - The size of digital stamp. { width: 50, //The width of digital stamp. height: 50 //The height of digital stamp } | Promise<void> | Set the default size of digital stamp. | pdfui.callAddonAPI( 'DigitalStampUIXAddon', 'setDefaultSize',[{width:100,height:100}])
  CustomDynamicStamp | setDynamicStamp | stampInfo - The custom dynamic stamp information. The width and height indicate the dimension of the stamp icon, and the rect represents the container for the custom text. The size of the rect should always be smaller than the size of the stamp icon, otherwise the stamp text will not appear on screen.Refer to STAMP_TEXT_TYPE for details of textType. [{ category:'xxx', name:'xxx', fileData:'xxx', // The URL of the stamp template, which supports both HTTP and Blob. the template type can be 'bmp','jpg','jpeg','png', 'webp', 'tif', and 'tiff'. width:290,//Optional.If the value is empty. the width dimension of the input image will be used. height:150,//Optional.If the value is empty, the height dimension of the input image will be used. field:{ textType:'xxx', // The type of the stamp text. value:'xxx', //The custom text. font:{ //Optional name:'xxx', //Font family. color:0, // Text color. size:18, //Text size. If set, the rect will be recalculated based on top and left }, rect:{ //{ PDFRect } Coordinate system of PDF coordinate system left:0, right:30, top:30, bottom:0, } }, }] | Promise<void> | Set custom dynamic stamp. | let param = [{ category:'xxx', name:'xxx', fileData:'xxx', field:{ textType:'xxx', value:'xxx', font:{ name:'xxx', color:0, }, rect:{ left:0, right:30, top:30, bottom:0, } }, }] pdfui.callAddonAPI( 'CustomDynamicStamp', 'setDynamicStamp',[param])
  CustomDynamicStamp | removeDynamicStamp | arr - The custom dynamic stamp category and name. [{ category:'xxx', names:['xxx'] }] | Promise<void> | Remove the custom dynamic stamp. | pdfui.callAddonAPI( 'CustomDynamicStamp', 'removeDynamicStamp',[[{category:'xxx',names:['xxx']}]])
  CustomDynamicStamp | getDynamicStamp | - | Promise<arr > -The custom dynamic stamp information. | Get the custom dynamic stamp. | pdfui.callAddonAPI( 'CustomDynamicStamp', 'getDynamicStamp')

Returns
  Promise<any>

## ◆ changeLanguage()

PDFUI::changeLanguage | ( |  | language | ) |
| inline

Switch UI language.

Parameters

  language | string - language, Now supported: en-US, zh-CN, zh-TW, de-DE, es-419, fr-FR, it-IT, ja-JP, nl-NL, ko-KR

Returns
  Promise<void>

## ◆ constructor()

PDFUI::constructor | ( |  | PDFUIOptions | ) |
| inline

Constructs a PDFUI instance.

Parameters

  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] | new(pdfUI:PDFUI)=>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:File|string)=>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.1, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 4, 6, 10], that has been used in marquee, loupe and zoom dropdown button in toolbar. The values must be within the minScale and maxScale ranges specified in the PDFViewer.constructor parameters.
  [options.customs.autoDownloadAfterSign] | boolean - True is the default value which means download automatically after signing, otherwise not.
  [options.customs.getSignedDocument] | (pdfBlob: Blob)=>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.
  [options.customs.progress] | ProgressComponent - Custom progress component for controlling progress. 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

## ◆ destroy()

PDFUI::destroy | ( |  | ) |
| inline

Destroys a PDFUI instance. The opening document will be closed and all component DOM elements will be destroyed.

Returns
  Promise<void>

## ◆ getAddonInstance()

PDFUI::getAddonInstance | ( |  | addonLibrary | ) |
| inline

Retrieves a loaded UIExtension (UIX) addon instance by its associated library name.

This method allows you to obtain a specific UIX addon instance based on the library name provided. The library name should match the 'library' property defined in the `addon.info.json` file of the addon.

Parameters

  addonLibrary | string - The library name of the UIX addon to retrieve.

Returns
  UIXAddon|undefined - The UIX addon instance associated with the provided library name, or undefined if the addon with the specified library name is not found.

Since
  9.2.0

Example of obtaining and using the Addon instance:
  const addonLibraryName = 'Thumbnail';
  pdfui.getAddonInstance(addonLibraryName).then(addonInstance => {
  if (addonInstance) {
  // You can now use the addonInstance to interact with the UIX addon.
  addonInstance.zoomTo(1);
  } else {
  console.error(`Addon with library name '${addonLibraryName}' was not found.`);
  }
  })

See also
  DigitalStampUIXAddon
  PrintUIXAddon
  ReadAloudAddon
  Thumbnail
  UndoRedoAddon

## ◆ getAllComponentsByName()

PDFUI::getAllComponentsByName | ( |  | name | ) |
| inline

Get all components which name is the specific string.

Parameters

  name | string - component name.

Returns
  Promise<Component[]>

## ◆ getAnnotationIcons()

async PDFUI::getAnnotationIcons | ( |  | annotType,
|  |  | onlyCustomized
| ) |  |
| inline

Get Customized icons.

Note
  Catagories and names parameter of StateHandlerManager.switchTo and PDFPage.addAnnot should be in returned object.

Parameters

  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.

Returns
  Promise<object> - Customize stamps. For example:
  {
  stamp:{ // annot type, currently only 'stamp' available.
  category1:{// Collection of icons
  name1: { // name of icon
  url:"xxx://xxx.png",//url for icon.
  type:"png",//Icon file type. 'bmp','jpg','jpeg','png' and 'pdf' available. For 'PDF', it should be a svg file (displaying in toolbar) url with same prefix with the 'PDF' file.
  }
  name2:{
  ...
  }
  }
  category2:{
  ...
  }
  }
  }

Since
  7.4.0

## ◆ getBookmarkUIService()

PDFUI::getBookmarkUIService | ( |  | ) |
| inline

Obtains the BookmarkUIService instance.

Returns
  BookmarkUIService - The singleton instance of BookmarkUIService.

Since
  10.0.0

## ◆ getComponentByName()

PDFUI::getComponentByName | ( |  | name | ) |
| inline

Get the first component which name is the specific string.

Parameters

  name | string - component name.

Returns
  Promise<Component>

## ◆ getCurrentLanguage()

PDFUI::getCurrentLanguage | ( |  | ) |
| inline

Get current language. Usually the language specified in the browser settings, if not supported it defaults to 'en-US'.

Returns
  string - Built-in supported language: 'en-US', 'zh-CN', 'de-DE', 'zh-TW', 'es-419', 'fr-FR', 'it-IT', 'ja-JP', 'nl-NL'.

Since
  8.5.0

## ◆ getPDFViewer()

PDFUI::getPDFViewer | ( |  | ) |
| inline

Get the PDFViewer instance asynchrounously.

Returns
  Promise<PDFViewer>

## ◆ getRootComponent()

PDFUI::getRootComponent | ( |  | ) |
| inline

Obtains the root component instance.

Returns
  Promise<Component>

## ◆ getSelectedTextInfo()

PDFUI::getSelectedTextInfo | ( |  | ) |
| 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:

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.
});

.

Returns
  Promise<{page: PDFPage, rectArray: Array<{left: number, right: number, top:number, bottom: number}>}>

## ◆ getSignatureService()

PDFUI::getSignatureService | ( |  | ) |
| inline

Alias of PDFViewer.getSignatureService. Obtains the SignatureService instance for customizing signature signing/verification behavior.

Returns
  SignatureService - The instance of the SignatureService.

Since
  11.0.0

See also
  PDFViewer.getSignatureService

## ◆ getSignatureWorkflowService()

PDFUI::getSignatureWorkflowService | ( |  | ) |
| inline

Retrieves the instance of SignatureWorkflowService.

This method retrieves an instance of the SignatureWorkflowService class. The service is responsible for handling signature workflows in the UIExtension level, including verifying signatures, managing signing settings, and setting override policies.

Returns
  SignatureWorkflowService - The instance of the SignatureWorkflowService.

Since
  11.0.0

## ◆ getStampService()

PDFUI::getStampService | ( |  | ) |
| inline

Obtains the StampService instance.

Returns
  StampService - The singleton instance of StampService.

Since
  9.0.0

## ◆ loading()

PDFUI::loading | ( |  | coverOn = `document.body`,
|  |  | text = `''`,
|  |  | animation = `true`
| ) |  |
| inline

Overlays a loading modal layer on a specified element.

Parameters

  [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.

Returns
  Promise<LoadingComponent>

## ◆ module()

static PDFUI::module | ( |  | name,
|  |  | deps
| ) |  |
| inline static

alias of Modular.module

Parameters

  name | string -
  deps | Array<string|UIXModule> -

See also
  Modular.module

Returns
  UIXModule

## ◆ openFormPropertyBoxAfterCreated()

PDFUI::openFormPropertyBoxAfterCreated | ( |  | isOpen | ) |
| inline

Set whether the properties box is displayed when creating a form field.

Parameters

  isOpen | boolean - Specifies whether to show the properties box. pdfui.openFormPropertyBoxAfterCreated(false)

## ◆ registerSignatureFlowHandler()

PDFUI::registerSignatureFlowHandler | ( |  | signatureHandler | ) |
| inline

Register the signature flow handler.

Parameters

  signatureHandler | SignatureFlowOptions - Custom signature process handler.

Examples
  function example (pdfui) {
  pdfui.registerSignatureFlowHandler({
  sign:(signField | {@link XFAWidgetInfo})=>{
  //do something
  return Promise.resolve({
  filter: 'Adobe.PPKLite',
  subfilter: 'adbe.pkcs7.sha1',
  flag: 0x1f0,
  distinguishName: 'e=foxitsdk@foxitsoftware.cn',
  location: 'FZ',
  reason: 'TestBJ',
  signer: 'web sdk11',
  defaultContentsLength:7942,
  image: 'data:image/png;base64,iVBORw0...',
  sign:(signInfo,plainBuffer)=>Promise<ArrayBuffer>
  })
  // Since version 11.0.0, this method has been deprecated. Please use SignatureWorkflowService#overrideSigningWorkflow instead, or
  // You can also customize the signing workflow by overriding the SignatureAnnot#startSigningWorkflow method using the ViewerAnnotManager#registerMatchRule method.
  },
  verify:(signField | {@link XFAWidgetInfo})=>{
  //do something
  // Since version 11.0.0, this method is deprecated, please use SignatureWorkflowService#overrideVerifyWorkflow instead!
  },
  showVerificationInfo:(signField | {@link XFAWidgetInfo})=>{
  // If you want to customize the information dialog for the result of verifying signature, you should implement this method,
  // and you also need to implement the 'verify' method.
  // Since version 11.0.0, this method is deprecated, you can customize signature verification result dialog by overriding the ISignatureUI#getSignVerifiedResultDialog method!
  },
  showSignatureProperty:(signField | {@link XFAWidgetInfo})=>{
  // If you want to customize the signature properties dialog, you should implement this method,
  // and you also need to implement the 'verify' method.
  // Since version 11.0.0, this method is deprecated, you can customize the signed signature property dialog by overriding the ISignatureUI#getSignedPropertiesDialog method!
  },
  getSigner:(signField | {@link XFAWidgetInfo})=>{
  // return the signer of the signature. It should be a string. Supported from version 10.0.
  // Since version 11.0.0, this method is deprecated, please use SignatureWorkflowService#setSignerOverridePolicy instead!
  }
  })
  }

Since
  8.4.0

See also
  SignatureAnnot.handleOnClick
  ISignatureUI
  SignatureWorkflowService

## ◆ registerSignaturePropertyHandler()

PDFUI::registerSignaturePropertyHandler | ( |  | handler | ) |
| inline

Register the signed properties dialog handler .

Parameters

  handler | (signatureInfo: object)=>object - If not passed, the default Dialog will display. { 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} }

Since
  8.0.0
  pdfui.registerSignaturePropertyHandler((signatureInfo)=>{})

Deprecated:
  This API is deprecated since version 11.0.0, and may be removed in the future.

See also
  ISignatureUI

## ◆ registerSignHandler()

PDFUI::registerSignHandler | ( |  | handler | ) |
| inline

Register signing handler.

Note
  This function can be called more than once.

Parameters

  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 | Signature_Ap_Flags - Appearance flags of signature. Please refer to Signature_Ap_Flags.
  handler.sign | (signInfo:object,plainBuffer:ArrayBuffer)=>Promise<ArrayBuffer> - Digest and sign handler.
  handler.timeFormat | object - Customize the date format.
  handler.timeFormat.format | string - The default is 'YYYY.MM.DD HH:mm:ss Z'.
  handler.timeFormat.timeZoneOptions | object - Used if the date format parameter contains 'Z'.
  handler.timeFormat.timeZoneOptions.separator | string - The default is '\''.
  handler.timeFormat.timeZoneOptions.prefix | string - The default is ''.
  handler.timeFormat.timeZoneOptions.showSpace | boolean - The default is 'true'.

Returns
  void -

Since
  8.3.0

Deprecated:

See also
  getSignatureWorkflowService

## ◆ removeUIEventListener()

PDFUI::removeUIEventListener | ( |  | type,
|  |  | listener
| ) |  |
| inline

Detach event listener from PDFUI instance by type and its callback function.

Parameters

  type | string|string[] - The event type which passed as the first parameter of PDFUI::addUIEventListener().
  listener | (...args:any[])=>void - The event callback function passed as the secondary parameter of PDFUI::addUIEventListener().

## ◆ removeViewerEventListener()

PDFUI::removeViewerEventListener | ( |  | type,
|  |  | listener
| ) |  |
| inline

Detach event listener from PDFViewer instance by type and its callback function.

Parameters

  type | string|string[] - The event type which passed as the first parameter of PDFUI.addViewerEventListener().
  listener | (...args:any[])=>void - The event callback function passed as the secondary parameter of PDFUI.addViewerEventListener().

Returns
  Promise<void>

## ◆ setDefaultMeasurementRatio()

PDFUI::setDefaultMeasurementRatio | ( |  | { userSpaceScaleValue=1, userSpaceUnit='inch', realScaleValue=1, realUnit='inch' } = `{}` | ) |
| inline

Set the default scale ratio for measuring.

Parameters

  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

Since
  8.0.0
  function example(pdfui){
  var {Annot_Unit_Type} = PDFViewCtrl.PDF.annots.constant
  pdfui.setDefaultMeasurementRatio({
  userSpaceScaleValue : 1,
  userSpaceUnit: Annot_Unit_Type.cm,
  realScaleValue: 1,
  realUnit : Annot_Unit_Type.cm
  })
  }

## ◆ setSnapshotInteractionClass()

PDFUI::setSnapshotInteractionClass | ( |  | interactionClass | ) |
| inline

Override the builtin interaction class, and customize the behavior of the snapshot tool buttons.

Parameters

  interactionClass | new(pdfViewer: PDFViewer, snapshot: Snapshot)=>SnapshotInteraction - A class inherits from SnapshotInteraction.

See also
  SnapshotInteraction

Returns
  void -

Since
  9.0.0

## ◆ setVerifyHandler()

PDFUI::setVerifyHandler | ( |  | handler | ) |
| inline

Register signature verifying handler.

Note
  It's recommended to call this function once. Otherwise old handler will be covered.

Parameters

  handler | (field:PDFFormField,plainBuffer:Uint8Array,signedData:Uint8Array)=>Promise<number> - Verifying handler which will return signature's state. Please refer to Signature_State.

Since
  7.4.0

Deprecated:

See also
  getSignatureService
  SignatureService

## ◆ waitForInitialization()

PDFUI::waitForInitialization | ( |  | ) |
| inline

A method returns a Promise instance that will be fullfilled after PDFUI completes initialization.

pdfui.waitForInitialization().then(() => {
pdfui.i18n.addResource('en-US', 'ui_', 'contextmenu.tools.handTool', 'Custom Hand Tool');
})

Returns
  Promise<void>

Since
  8.0.0

@2025 Foxit Software Incorporated. All rights reserved.