FoxitPDFSDKforWeb  7.1.1
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...
 
 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...
 
 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, i18n, i18nOptions, eventEmitter=new EventEmitter(), minScale=0.1, maxScale=10, defaultScale='fitWidth', preloadedPages=1, scaleFrequency=4, tileSize=3600, StateHandlers=[], customs={}, keymap={}, Viewmodes=[], enableJS, stateHandlerConfig, watermarkConfig, actionOptions={}, defaultViewMode=continuousViewModeName, snapshotServer=new SnapshotServer({ uploadSnapshotAPIPath:'snapshot/upload' }), highPerformance=typeof WebAssembly==='object', }={})
 Create a PDFViewer. More...
 
 createNewDoc (title="untitled.pdf", author="", pageSize={height:842, width:595})
 Create a new pdf document. More...
 
 getAnnotManager ()
 Get annotation component manager. More...
 
 getAnnotRender (pageIndex, name)
 GetAnnotRender 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)
 Init PDFViewer. More...
 
 openPDFByFile (file, options={}, pdfEngine)
 Open the local document. More...
 
 openPDFByHttpRangeRequest (request, options={fileName:''})
 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 page view. 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...
 
 setEnableJS (enable)
 Set whether JavaScript is allowed or not. More...
 
 setUserName (userName)
 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
typestring - the event type, all event types are defined in UIExtension::UIEvents.
listenerfunction - 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
typestring - the event type, all event types defined in UIExtension::PDFViewCtrl::Events.
listenerfunction - the event callback function.
Returns
function - a function to remove this event binding.

◆ changeLanguage()

PDFUI::changeLanguage (   language)
inline

Switch UI language.

Parameters
languagestring - language, en-US, zh-CN
Returns
Promsie<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.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 templat format, you must rewrite this template otherwise many unpredicatable errors will occur.
[options.i18n]object - The options for i18next(an internationalization-framework), for more details please visit https://www.i18next.com/overview/configuration-options
[options.customs]object - Some customize options
[options.customs.defaultStateHander]PDFViewCtrl.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
namestring - component name.
Returns
Promise<Component[]>

◆ getComponentByName()

PDFUI::getComponentByName (   name)
inline

Get the first component which name is the specific string.

Parameters
namestring - component name.
Returns
Promise<Component>

◆ getPDFViewer()

PDFUI::getPDFViewer ( )
inline

Get the PDFViewer instance asynchrounously.

Returns
Promise.<PDFViewer>

◆ 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
typestring - The event type which passed as the first parameter of PDFUI::addUIEventListener().
listenerfunction - 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 - The event type which passed as the first parameter of PDFUI.addViewerEventListener().
listenerfunction - 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.