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

Public Member Functions

 addUIEventListener (type, listener)
 Attach an event listener to PDFUI instance by type. More...
 
 addViewerEventListener (type, listener)
 Attach an event listener to PDFViewer instance by type. More...
 
 callAddonAPI (addonLibrary, action, args=[])
 Trigger an action to specified Addon. More...
 
 changeLanguage (language)
 Switch UI language. More...
 
 constructor (PDFUIOptions)
 Constructs a PDFUI instance. More...
 
 destroy ()
 Destroys a PDFUI instance. The opening document will be closed and all component DOM elements will be destroyed. More...
 
 getAllComponentsByName (name)
 Get all components which name is the specific string. More...
 
 getComponentByName (name)
 Get the first component which name is the specific string. More...
 
 getPDFViewer ()
 Get the PDFViewer instance asynchrounously. More...
 
 getRootComponent ()
 Obtains the root component instance. More...
 
 getSelectedTextInfo ()
 Gets the currently selected text information, including the text boundary rectangle in point unit based on the PDF page coordinates, the PDFPage instances and text content. If there's no text is selected, this method returns a none value promise instance. The PDF point unit of the rectangle can be converted to device pixels, as shown in the following example: More...
 
 loading (coverOn=document.body, text='', animation=true)
 Overlays a loading modal layer on a specified element. 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...
 
- Public Member Functions inherited from PDFViewer
 close (before=this.customs.closeDocBefore, after=this.customs.closeDocAfter)
 Close the open document. More...
 
 constructor ({ preloadJR=true, preloadSR=false, libPath, jr, sr, i18n, i18nOptions, eventEmitter=new EventEmitter(), minScale=0.1, maxScale=10, defaultScale='fitWidth', scaleFrequency=4, tileSize=1200, getTileSize=null, StateHandlers=[], customs={}, keymap={}, Viewmodes=[], enableJS, enableSafeMode, stateHandlerConfig, watermarkConfig, actionOptions={}, defaultViewMode=continuousViewModeName, snapshotServer=new SnapshotServer({ uploadSnapshotAPIPath:'snapshot/upload' }), highPerformance=typeof WebAssembly==='object', annotRenderingMode={}, defaultKeyboardEventBinder=VIEWER_BINDER, defaultAnnotConfig, enableSignature=true, }={})
 Create a PDFViewer. More...
 
 createNewDoc (title="untitled.pdf", author="", pageSize={height:842, width:595}, pdfEngine=this.pdfEngine)
 Create a new pdf document. More...
 
 getAnnotManager ()
 Get annotation component manager. More...
 
 getAnnotRender (pageIndex, name)
 Get annot render. PDFPageRender::getAnnotRender. More...
 
 getCurrentPDFDoc ()
 Get current pdf doc object. More...
 
 getEnableJS ()
 Checks if PDF js can be executed. More...
 
 getEventEmitter ()
 Get event emitter. More...
 
 getPDFDocRender ()
 GetPDFDocRender. More...
 
 getPDFPageRender (index)
 GetPDFPageRender PDFDocRender::getPDFPageRender. More...
 
 getStateHandlerManager ()
 Get state handler manager. More...
 
 getViewModeManager ()
 Get view mode manager. More...
 
 init (selector)
 Initialize PDFViewer. More...
 
 killFocus ()
 Kill the focus of activated element. 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...
 
 redraw (force)
 Redraw the currently visible page(s). More...
 
 registerSignatureHandler (filter, subfilter, handler)
 Register a signature handler. 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...
 
 setDefaultAnnotConfig (fn)
 Set the default configured callback function for the annotation.See PDFPage::addAnnot for the return object format. More...
 
 setEnableJS (enable)
 Set whether JavaScript is allowed or not. More...
 
 setJRFontMap (fontMaps)
 Set JR custom font. More...
 
 setUserName (userName, pdfEngine=this.pdfEngine)
 Set the global username. More...
 
 zoomTo (scale)
 Zoom to the given scale. More...
 

Detailed Description

Member Function Documentation

◆ addUIEventListener()

PDFUI::addUIEventListener (   type,
  listener 
)
inline

Attach an event listener to PDFUI instance by type.

Parameters
type{string|string[]} - 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[]} - the event type, all event types defined in UIExtension::PDFViewCtrl::Events.
listener{Function} - 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 example
UndoRedoAddon undo - pdfui.callAddonAPI("UndoRedoAddon","undo")
redo - pdfui.callAddonAPI("UndoRedoAddon","redo")
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]{Array<string>} - uix addons paths
[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.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.templateParser]{TemplateParser} - custom template parser, by default is XMLTtemplateParser, if your custom template format is not compatible with the internal format, you need to overwrite defaultFragments and template option, otherwise many unpredictable errors will occur.

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

◆ getComponentByName()

PDFUI::getComponentByName (   name)
inline

Get the first component which name is the specific string.

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

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

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

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