FoxitPDFSDKforWeb  v10.0.0
Foxit PDF SDK for Web
PDFUI Class Reference
Inheritance diagram for PDFUI:
PDFViewer Disposable

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

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

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

. More...

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

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

. More...

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

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

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
fontsstring[] - 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
typestring|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
typestring|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
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")
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','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.
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',
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
languagestring - language, en-US, zh-CN
Returns
Promise<void>

◆ constructor()

PDFUI::constructor (   PDFUIOptions)
inline

Constructs a PDFUI instance.

Parameters
optionsobject - options to create PDFUI
options.viewerOptionsobject - The options for creating PDFViewer;
options.renderToHTMLElement|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
addonLibrarystring - 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
namestring - 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
annotTypestring - The annotation’s icon type. Currently only ‘stamp’ is available.
onlyCustomizedboolean - 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
namestring - 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}>}>

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

alias of Modular.module

Parameters
namestring -
depsArray<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
isOpenboolean - Specifies whether to show the properties box.
pdfui.openFormPropertyBoxAfterCreated(false)

◆ registerSignatureFlowHandler()

PDFUI::registerSignatureFlowHandler (   signatureHandler)
inline

Register the signature flow handler.

Parameters
signatureHandlerSignatureFlowOptions - Custom signature process handler.
Examples
function example (pdfui) {
pdfui.registerSignatureFlowHandler({
sign:(signField)=>{
//do something
return Promise.resolve({
filter: 'Adobe.PPKLite',
subfilter: 'adbe.pkcs7.sha1',
flag: 0x1f0,
distinguishName: '[email protected]',
location: 'FZ',
reason: 'TestBJ',
signer: 'web sdk11',
defaultContentsLength:7942,
image: 'data:image/png;base64,iVBORw0...',
sign:(signInfo,plainBuffer)=>Promise<ArrayBuffer>
})
},
verify:(signField)=>{
//do something
},
showVerificationInfo:(signField)=>{
// 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.
},
showSignatureProperty:(signField)=>{
// If you want to customize the signature properties dialog, you should implement this method,
// and you also need to implement the 'verify' method.
},
getSigner:(signField)=>{
// return the signer of the signature. It should be a string. Supported from version 10.0.
}
})
}
Since
8.4.0

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

◆ registerSignHandler()

PDFUI::registerSignHandler (   handler)
inline

Register signing handler.

Note
This function can be called more than once.
Parameters
handlerobject - Signing handler.
handler.filterstring - Filter of this handler.
handler.subfilterstring - Subfilter of this handler.
handler.signerstring - Singer name of this handler.
handler.distinguishNamenumber - Distinguish name (DN) of signature.
handler.locationnumber - Location of signature.
handler.reasonnumber - Reason of signature.
handler.defaultContentsLengthnumber - 7942 is the default length of signature contents, in bytes. It should not be less than 4098.
handler.flagSignature_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.timeFormatobject - Customize the date format.
handler.timeFormat.formatstring - The default is 'YYYY.MM.DD HH:mm:ss Z'.
handler.timeFormat.timeZoneOptionsobject - Used if the date format parameter contains 'Z'.
handler.timeFormat.timeZoneOptions.separatorstring - The default is '\''.
handler.timeFormat.timeZoneOptions.prefixstring - The default is ''.
handler.timeFormat.timeZoneOptions.showSpaceboolean - 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
typestring|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
typestring|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
optionsobject - options of measurement information
options.userSpaceScaleValuenumber - Set the ratio value in user space.
options.userSpaceUnitstring - Set the ratio unit in user space. Only 'inch,pt,cm,mm,pica' types are supported. Please refer to Annot_Unit_Type
options.realScaleValuenumber - Set the ratio value in real space.
options.realUnitstring - 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
interactionClassnew(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:PDFField,plainBuffer:Uint8Array,signedData:Uint8Array)=>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
@2024 Foxit Software Incorporated. All rights reserved.