FoxitPDFSDKforWeb  8.5.0
Foxit PDF SDK for Web
PDFUI Class Reference
Inheritance diagram for PDFUI:
PDFViewer

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

 
 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...
 
- 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...
 
 close (before=this.customs.closeDocBefore, after=this.customs.closeDocAfter, options={})
 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...
 
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=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 (type)
 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...
 
 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...
 

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...
 
i18next i18n
 I18next instance. More...
 

Detailed Description

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
{Array<string>}fonts - 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[]|{[string]:Function}} - the event type, all event types are defined in UIExtension::UIEvents.
listener{Function} - the event callback function
Returns
{Function} - 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[]|{[string]:Function}} - the event type, all event types defined in ViewerEvents.
listener[Function] - (Optional if type is a map object)The event callback function.
Returns
{Function} - a function to remove this event binding.

◆ callAddonAPI()

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

Trigger an action to specified Addon.

Parameters
addonLibrarystring - refer to the 'library' property defined in addon.info.json file of the addon
actionstring - action name
argsany[]
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")
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);
}]
)

Returns
Promise<any>

◆ changeLanguage()

PDFUI::changeLanguage (   language)
inline

Switch UI language.

Parameters
language{string} - language, en-US, zh-CN
Returns
{Promsie<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]{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.

◆ 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>}

◆ getAllComponentsByName()

PDFUI::getAllComponentsByName (   name)
inline

Get all components which name is the specific string.

Parameters
name{string} - component name.
Returns
{Promise<Component[]>}

◆ getAnnotationIcons()

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

◆ 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, rectArray: Array<{left,right,top,bottom}>}>

◆ 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 
)
inlinestatic

alias of Modular.module

Parameters
name{string}
deps{Array<string|UIXModule>}
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 (   handler)
inline

Register the signature flow handler.

Parameters
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.
Since
8.4.0
function example (pdfui) {
pdfui.registerSignatureFlowHandler((signField)=>{
//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>
})
})
}

◆ registerSignaturePropertyHandler()

PDFUI::registerSignaturePropertyHandler (   handler)
inline

Register the signed properties dialog handler .

Parameters
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}
}
Since
8.0.0
pdfui.registerSignaturePropertyHandler((signatureInfo)=>{})

◆ 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{number} - Appearance flags of signature. Please refer to Signature_Ap_Flags.
handler.sign{(signInfo,plainBuffer)=>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'.
Since
8.3.0

◆ 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{Function} - 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{Function} - 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
})
}

◆ 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,plainBuffer,signedData)=>Promise<number} - Verifying handler which will return signature's state. Please refer to Signature_State.
Since
7.4.0

◆ 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

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