WebViewer Instance Core namespace.
The namespace containing WebViewer's core user controls, including DocumentViewer control and the Document class.
Example
webViewerInstance.Core.someProperty webViewerInstance.Core.someAPI()
Classes
- AnnotationHistoryManager
- AnnotationManager
- Bookmark
- ContentEditManager
- DisplayMode
- DisplayModeManager
- Document
- DocumentViewer
- EditBoxManager
- EventHandler
- FormFieldCreationManager
- MeasurementManager
- Scale
- VirtualDisplayMode
- WebViewerServerAnnotationManager
Namespaces
Members
-
<static> annotationManager
-
AnnotationManager instance
Type:
Example
WebViewer(...) .then(function(instance) { const annotationManager = instance.Core.annotationManager; });
-
<static> BackendTypes
-
The types of backend workers.
Properties:
Name Type Description ASM
string 'asm' Use of ASM.js worker. WASM
string 'ems' Use of the WebAssembly worker (or ASM.js on non-wasm browsers). THREADED_WASM
string 'wasm-threads' Use of threaded WebAssembly worker. -
<static> ColorPostProcessMode
-
Represents the different color post processing options that can used in the updateRasterizerOptions function.
Properties:
Name Type Description NONE
number No post processing. This is the default setting INVERT
number Inverted color mode GRADIENT_MAP
number Gradient color mode NIGHT_MODE
number Night mode -
<static> DisplayModes
-
Display modes that control how the document's page are displayed
Type:
- string
Properties:
Name Type Description Single
string Displays one page at a time. Continuous
string Displays all the pages in a scrolling view in one column. Facing
string Displays up to two pages at a time, side by side. FacingContinuous
string Displays all pages in a scrolling view in two columns. Cover
string Displays all pages in a scrolling view in two columns. The first row has a single page in the second column. CoverFacing
string Same as the Cover display mode except that it is not a scrolling view. Custom
string Any custom display mode. -
<static> documentViewer
-
DocumentViewer instance
Type:
- See:
Example
WebViewer(...) .then(function(instance) { const documentViewer = instance.Core.documentViewer; });
-
<static> FONT_STYLES
-
Represents the font style for the watermark text
Properties:
Name Type Description BOLD
string specifies that the text should be bolded ITALIC
string specifies that the text should be italicized UNDERLINE
string specifies that the text should be underlined -
<static> getLegacyOfficeWorkerPath
-
Get the location of the Legacy Office worker (WebB2XOfficeWorker).
-
<static> getOfficeWorkerPath
-
Get the location of the Office worker.
-
<static> getResourcePath
-
Get the location of the ContentEdit worker resource file InfixServerWasm.br.mem
-
<static> getWorkerPath
-
Get the location of the ContentEdit worker files InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem
-
<static> MarkedStates
-
Represents the different Marked state values that you can apply to annotation status.
Type:
- string
Properties:
Name Type Description Marked
string Marked State Unmarked
string Unmarked State -
<static> PageRotation
-
Represents the different page rotation values that you can apply to pages.
Type:
- number
Properties:
Name Type Description E_0
number 0 degree rotation E_90
number 90 degree rotation E_180
number 180 degree rotation E_270
number 270 degree rotation -
<static> ReviewStates
-
Represents the different review state values that you can apply to annotation status.
Type:
- string
Properties:
Name Type Description Accepted
string Accepted State Rejected
string Rejected State Cancelled
string Cancelled State Completed
string Completed State None
string None State -
<static> SaveOptions
-
Represents the different save option values that you can use in the getFileData function.
Properties:
Name Type Description INCREMENTAL
number Saves new data to the end of the file REMOVE_UNUSED
number Removes unused data when saving HEX_STRINGS
number Save strings in hexadecimal format OMIT_XREF
number Do not save cross reference table LINEARIZED
number Optimize data for speed and remove unused data COMPATIBILITY
number Maximize compatibility with older PDF consumers (e.g. the file will not use object and compressed XREF streams) -
<static> setBasePath
-
Setting the base path that relatively loading documents will be relative to.
-
<static> setLegacyOfficeWorkerPath
-
Set the location of the Legacy Office worker (WebB2XOfficeWorker). This will override the location specified by Core.setWorkerPath for Legacy Office worker files.
-
<static> setOfficeWorkerPath
-
Set the location of the Office worker. This will override the location specified by Core.setWorkerPath for Office worker files.
-
<static> setResourcePath
-
Set the location of the ContentEdit worker resource file InfixServerWasm.br.mem This will override the location specified by Core.setWorkerPath for InfixServerWasm.br.mem file.
-
<static> setWorkerPath
-
Set the location of the ContentEdit workers for InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem files. This will override the location specified by Core.setWorkerPath for ContentEdit worker files.
-
<static> StateModel
-
Represents the different state models that you can apply to annotation.
Type:
- string
Properties:
Name Type Description Marked
string Marked State Review
string Review State -
<static> SupportedFileFormats
-
Represents all the supported file formats in WebViewer
Properties:
Name Type Description CLIENT
Array.<string> Supported file formats when using WebViewer client side rendering SERVER
Array.<string> Supported file formats when using WebViewer with WebViewer Server -
<static> TextExtractorProcessingFlags
-
Represents the different processing option values to direct the flow of content recognition algorithms that you can use in the setTextExtractorProcessingFlags function.
Properties:
Name Type Description NO_LIGATURE_EXP
number Disables expanding of ligatures using a predefined mapping. Default ligatures are: fi, ff, fl, ffi, ffl, ch, cl, ct, ll, ss, fs, st, oe, OE NO_DUP_REMOVE
number Disables removing duplicated text that is frequently used to achieve visual effects of drop shadow and fake bold PUNCT_BREAK
number Treat punctuation (e.g. full stop, comma, semicolon, etc.) as word break characters REMOVE_HIDDEN_TEXT
number Enables removal of text that is obscured by images or rectangles NO_INVISIBLE_TEXT
number Enables removing text that uses rendering mode 3 (i.e. invisible text), which is usually used in 'PDF Searchable Images' (i.e. scanned pages with a corresponding OCR text) NO_WATERMARKS
number Enables removal of text that is marked as part of a Watermark layer EXTRACT_USING_ZORDER
number Use Z-order as reading order for text
Methods
-
<static> areObjectURLBlobsEnabled()
-
Retrieves the current boolean value of the internal property objectURLBlobsDisabled
Returns:
- Type
- boolean
-
<static> BaseDocument()
-
BaseDocument is used to alert if a Document implementation is not following the Document interface.
-
<static> createDatePicker(options)
-
Create DatePicker UI
Parameters:
Name Type Description options
Object An object to set the configuration of the date picker Properties
Name Type Description field
HTMLElement The HTML form field the date picker should be bound to container
HTMLElement DOM node to render calendar into onDateSelected
Core.onDateSelected Function that is called when the date is selected from the date picker UI format
string the date format showed after select date -
<static> createDocument(src [, options])
-
Creates an initialized Core.Document instance.
Parameters:
Name Type Argument Description src
string | File | ArrayBuffer | Blob | Core.PDFNet.PDFDoc Source parameter, path/url to document or File. options
Core.CreateDocumentOptions <optional>
Create document options. Returns:
Promise that resolves when doc.loadAsync has been successfully called and returns Core.Document instance.- Type
- Promise.<Core.Document>
-
<static> disableEmbeddedJavaScript()
-
Disables the execution of embedded JavaScript
-
<static> disableFullPDF()
-
Disable the use of the full version of the PDFNetJS if it had been previously enabled.
-
<static> disableLogs(disabled)
-
Enables or disables all logs coming from WebViewer.
Parameters:
Name Type Description disabled
boolean Whether or not to disable all WebViewer logs. Defaults to true -
<static> disableObjectURLBlobs(value)
-
Sets the internal boolean property of objectURLBlobsDisabled. If false, then the URL.createObjectUrl API will be used to instantiate an uncompressed Blob instance of the appropriate PDF worker file (Note that this goes against the Content-Security-Policy (CSP) rule "script-src blob:"). If true, then uncompressed JavaScript files will be loaded without instantiating a Blob.
Parameters:
Name Type Description value
boolean The boolean value to set the internal boolean property of objectURLBlobsDisabled. -
<static> disableOptimizedWorkers()
-
Set flag to indicate that the optimized workers can not be used.
- See:
-
- Core.enableOptimizedWorkers for more details.
-
<static> enableFullPDF()
-
Enable or disable use of the full version of PDFNetJS. the parameter is deprecated since version 8.0
-
<static> enableOptimizedWorkers()
-
Set flag to indicate that the optimized workers can be used. These workers require some wasm features, e.g. Fixed-Width SIMD, Exception Handling, Bulk Memory Operations. If the browser doesn't support these features, this will have no effect.
-
<static> enableWorkerLogs(enabled)
-
Enables or disables logs from the PDF worker.
Parameters:
Name Type Description enabled
boolean Whether or not to enable PDF worker logs. Defaults to false. -
<static> forceBackendType(backendType)
-
Set default backend type. This method can be used for forced backend type for specific workers, for example, "ems" for Emscripten worker type
Parameters:
Name Type Description backendType
string Value for default backend type, e.g. asm, ems, wasm-threads, jsworker. -
<static> getAllowedFileExtensions()
-
Get the array of allowed file extensions. An empty array indicates all supported file extensions are allowed.
-
<static> getBuild()
-
Returns the specific hashed commit id that is used to build the current WebViewer version.
Returns:
A hashed commit id- Type
- string
-
<static> getCanvasMultiplier()
-
Gets the default multiplier used for rendering pages with document.loadCanvas. Higher multipliers mean that pages will be rendered at higher resolutions. The default value is the browser's devicePixelRatio
Returns:
The current value of the canvas multiplier- Type
- number
-
<static> getCurrentOfficeBackendType()
-
Gets the current backend type being used.
Returns:
Returns "asm" if ASM.js is being forced, "ems" if Emscripten is being used, "wasm-threads" if threaded Wasm is being used and undefined if nothing is being used yet- Type
- string
-
<static> getCurrentPDFBackendType()
-
Gets the current backend type being used.
Returns:
Returns "asm" if ASM.js is being forced, "ems" if Emscripten is being used, "wasm-threads" if threaded Wasm is being used and undefined if nothing is being used yet- Type
- string
-
<static> getCurrentPDFBackendType()
-
Gets the current backend type loaded or being loaded
Returns:
Returns "asm" if ASM.js is being forced, "ems" if Emscripten is being used or "wasm-threads" if threaded Wasm is being used- Type
- Promise.<string>
-
<static> getDefaultBackendType()
-
Gets the default pdf backend type that should be used for this browser.
Returns:
Returns a promise that resolve to a string. "ems" if Emscripten should be used, and "wasm-threads" if threaded Wasm should be used- Type
- Promise.<string>
-
<static> getDocumentViewers()
-
Gets an array of currently instantiated documentViewer objects.
Returns:
Array of documentViewer objects that are being used for the UI- Type
- Array.<Core.DocumentViewer>
Example
WebViewer(...) .then(function(instance) { const documentViewerList = instance.Core.getDocumentViewers(); documentViewerList.forEach(documentViewer => documentViewer.loadDocument(doc, options)); });
-
<static> getExternalPath()
-
Get the location of external scripts.
Returns:
the prefix url external scripts.- Type
- string
-
<static> getHashParam(property, defaultValue)
-
Gets the value of the specified hash parameter from the window URL
Parameters:
Name Type Description property
string The property key from hash parameter defaultValue
T Default return value - Deprecated:
-
- Since version 8.3. Please use getHashParameter instead
Returns:
A value of the hash parameter- Type
- T
-
<static> getHashParameter(property, defaultValue)
-
Gets the value of the specified hash parameter from the window URL
Parameters:
Name Type Description property
string The property key from hash parameter defaultValue
T Default return value Returns:
A value of the hash parameter- Type
- T
-
<static> getLegacyOfficeAsmPath()
-
Get the location of the LegacyOffice asm worker.
Returns:
the prefix url for WebB2XOfficeWorker.br.js.mem.- Type
- string
-
<static> getLegacyOfficeResourcePath()
-
Get the location of the Legacy Office resource worker.
Returns:
the prefix url for WebB2XOfficeWorker.js- Type
- string
-
<static> getLocalWorkerPath()
-
Get the location of the local worker files.
Returns:
the path to CORSWorker.js/CoreWorker.js- Type
- string
-
<static> getOfficeAsmPath()
-
Get the location of the Office asm worker.
Returns:
the prefix url for WebOfficeWorker.br.js.mem.- Type
- string
-
<static> getOfficeResourcePath()
-
Get the location of the Office worker.
Returns:
the prefix url for OfficeWorker.js- Type
- string
-
<static> getPDFAsmPath()
-
Get the location of the PDF asm.js file PDFNetC.gz.js.
Returns:
the prefix url for PDFNetC.gz.js.- Type
- string
-
<static> getPDFResourcePath()
-
Get the location of PDF resources.
Returns:
the prefix url for PDFNetC.js.mem and PDFNet.res.- Type
- string
-
<static> getPDFWorkerPath()
-
Get the location of the PDF worker.
Returns:
the prefix url for PDFworker.js- Type
- string
-
<static> getResourcesPath()
-
Gets the path to the resources folder
Returns:
The path to the resources folder- Type
- string
-
<static> getScrollLeft(ele)
-
Gets the scrollLeft value for the element. Takes into account right to left scrolling direction if applicable.
Parameters:
Name Type Description ele
Element An HTML element to retrieve the scrollLeft value from Returns:
The scrollLeft value of the element- Type
- number
-
<static> getVersion()
-
Returns the WebViewer version.
Returns:
WebViewer version- Type
- string
-
<static> getWebViewerServerAnnotationManager()
-
Gets an instance of WebViewerServerAnnotationManager
Returns:
Resolves with a new instance of WebViewerServerAnnotationManager- Type
- Promise.<Core.WebViewerServerAnnotationManager>
-
<static> getWorkerPath()
-
Gets the path to the Web Worker JavaScript file
Returns:
The path to the worker- Type
- string
-
<static> hexStringToNumberArray(hexString)
-
Converts hexadecimal string to a number array.
Parameters:
Name Type Description hexString
string String of hexadecimal characters -
<static> initLegacyOfficeWorkerTransports(officeType, workerHandlers)
-
Begins setup of Legacy Office Worker Object.
Parameters:
Name Type Description officeType
string object representing an Office backend type ("ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress, emsWorkerError). Returns:
a promise that will be resolved when worker transport initialization is complete. -
<static> initOfficeWorkerTransports(officeType, workerHandlers, l)
-
Begins setup of Office Worker Object.
Parameters:
Name Type Description officeType
string object representing an Office backend type ("ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress, emsWorkerError). l
string The license key to use for this worker. If undefined, initialization will be done in demo mode. Returns:
a promise that will be resolved when worker transport initialization is complete. -
<static> initPDFWorkerTransports(pdfBackendType, workerHandlers, l)
-
Begins setup of PDF Worker Object.
Parameters:
Name Type Description pdfBackendType
string object representing an PDF backend type ("asm", "ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress, emsWorkerError). l
string The license key to use for this worker. If undefined PDFNet will be initialized in demo mode. Returns:
a promise that will be resolved when worker transport initialization is complete. -
<static> isBlendModeSupported(type)
-
Check if a composite operation is supported
Parameters:
Name Type Description type
string Composite operation to check Returns:
True if if the input composite operation is supported, false otherwise- Type
- boolean
-
<static> isDemoMode()
-
Returns whether demo mode is active or not. Must be called after the document is loaded or after the call to Core.initPDFWorkerTransports if you're calling it directly.
Returns:
true or false depending on whether the viewer is in demo mode or not- Type
- boolean
-
<static> isFullPDFEnabled()
-
Returns whether the full version of PDFNetJS is enabled or not.
Returns:
returns true if the full version is enabled and false otherwise.- Type
- boolean
-
<static> office2PDFBuffer(input, options)
-
Parameters:
Name Type Description input
string | ArrayBuffer Either a url from which to download the file or an ArrayBuffer containing the file data. options
Object An object containing conversion options Properties
Name Type Argument Description l
string <optional>
The license key with which to initialize the SDK extension
string <optional>
The extension of the input file. Should be passed in if the input doesn't specify the file extension. - Deprecated:
-
- Since version 8.3. Please use officeToPDFBuffer instead
Returns:
A promise that resolves to an ArrayBuffer containing the resulting PDF data.- Type
- ArrayBuffer
-
<static> officeToPDFBuffer(input, options)
-
Parameters:
Name Type Description input
string | ArrayBuffer Either a url from which to download the file or an ArrayBuffer containing the file data. options
Object An object containing conversion options Properties
Name Type Argument Description l
string <optional>
The license key with which to initialize the SDK extension
string <optional>
The extension of the input file. Should be passed in if the input doesn't specify the file extension. Returns:
A promise that resolves to an ArrayBuffer containing the resulting PDF data.- Type
- ArrayBuffer
-
<static> preloadLegacyOfficeWorker(officeBackendType, workerHandlers)
-
Begins setup of Legacy Office Worker Object. This can be used to load the workers before a license key has been loaded.
Parameters:
Name Type Description officeBackendType
string object representing an Office backend type ("ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress). Returns:
The worker object- Type
- object
-
<static> preloadOfficeWorker(officeBackendType, workerHandlers)
-
Begins setup of Office Worker Object. This can be used to load the workers before a license key has been loaded.
Parameters:
Name Type Description officeBackendType
string object representing an Office backend type ("asm", "ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress). Returns:
The worker object- Type
- object
-
<static> preloadPDFWorker(pdfBackendType, workerHandlers)
-
Begins setup of PDF Worker Object. This can be used to load the workers before a license key has been loaded.
Parameters:
Name Type Description pdfBackendType
string object representing a PDF backend type ("asm", "ems" or "wasm-threads") workerHandlers
object object holding event and error handlers for the worker (workerLoadingProgress). Returns:
The worker object- Type
- object
-
<static> resetLegacyOfficeWorker(worker)
-
Resets the worker so that the next time initLegacyOfficeWorkerTransports is called it will set up the worker transports with the specified worker.
Parameters:
Name Type Description worker
object The new worker to use the next time initLegacyOfficeWorkerTransports is called -
<static> resetOfficeWorker(worker)
-
Resets the worker so that the next time initOfficeWorkerTransports is called it will set up the worker transports with the specified worker.
Parameters:
Name Type Description worker
object The new worker to use the next time initOfficeWorkerTransports is called -
<static> resetWorker()
-
Resets the worker so that the next time initPDFWorkerTransports is called it will set up the worker transports.
-
<static> setAdvancedImageScaling(advanced)
-
Forces a higher level of accuracy in image downsampling at the expense of rendering performance. This function should be called before loading a document to ensure this setting is used.
Parameters:
Name Type Description advanced
boolean if true advanced image scaling will be used. Can alternatively pass a number for the number of downsampling steps to take. Passing true is equivalent to passing 1.4. -
<static> setAllowedFileExtensions(fileExtensionArray)
-
Set the allowed file extensions.
Parameters:
Name Type Description fileExtensionArray
Array.<string> An array of file extensions, not case sensitive. An empty array will allow any supported file extension to be loaded. -
<static> setAsWindowsApp()
-
Flag WebViewer as running inside a Windows App so that it automatically uses the WinRTPartRetriever for loading local XOD files
-
<static> SetCachingLevel(level)
-
Set the caching level between 0 and 20, where 0 is no caching and 20 uses a very large cache. The default is 10.
Parameters:
Name Type Description level
number The level to set -
<static> setCanvasMultiplier(value)
-
Sets the default multiplier used for rendering pages with document.loadCanvas. Higher multipliers mean that pages will be rendered at higher resolutions. The default value is the browser's devicePixelRatio
Parameters:
Name Type Description value
number The value of multiplier to be set -
<static> setColorManagement( [boolean])
-
Enables or color management for PDFNetJS backend. Color management is off by default. Enabling color management will better reflect correct color conversions but has a performance penalty.
Parameters:
Name Type Argument Description boolean
<optional>
value if true enable color management. Otherwise disable it. -
<static> setCustomFontURL(url)
-
Set the URL at which PDFNetJS backend will request font resources for the purposes of font substitution. By default they are retrieved from the pdftron website.
Parameters:
Name Type Description url
string The url at which font resources should be requested. -
<static> setEmscriptenHeapSize(The)
-
Adjusts the up front heap size used by Emscripten. This method must be called before the worker is initialized to change heap allocation behaviour. By default the heap size is set to 50331648 bytes. Note that decreasing the heap size very low or running complex operations may require a resize.
Parameters:
Name Type Description The
number number of bytes to allocate for the Emscripten heap. -
<static> setExternalPath()
-
Set the location of external scripts.
-
<static> setIsWindowsApp(isWindowsApp)
-
Sets whether WebViewer is running inside a Windows App and should automatically use the WinRTPartRetriever for loading local XOD files
Parameters:
Name Type Description isWindowsApp
boolean Whether WebViewer is running inside a Windows app or not - Deprecated:
-
- since version 8.0 Please use setAsWindowsApp or unsetAsWindowsApp instead
-
<static> setLegacyOfficeAsmPath(workerPath)
-
Set the location of the LegacyOffice asm worker. This will override the location specified by Core.setWorkerPath for Office worker files.
Parameters:
Name Type Description workerPath
string the prefix url for WebB2XOfficeWorker.br.js.mem. -
<static> setLegacyOfficeResourcePath(workerPath)
-
Set the location of the Legacy Office resource worker. This will override the location specified by Core.setWorkerPath for Legacy Office worker files This new legacyOfficeResourcePath will be used in very specific situations where worker files are located in different locations.
Parameters:
Name Type Description workerPath
string the prefix url for WebB2XOfficeWorker.js and .mem files -
<static> setLocalWorkerPath(workerPath [, isExact])
-
Sets the location of the local worker files CORSWorker.js/CoreWorker.js which will be different when setting the main worker path to another domain. Note that this path should be on the same domain as WebViewer is being loaded.
Parameters:
Name Type Argument Description workerPath
string The path to the local worker files isExact
boolean <optional>
By default this function will add a trailing slash if it wasn't added but in rare cases you may not want this behavior and can pass true for isExact -
<static> setOfficeAsmPath(workerPath)
-
Set the location of the Office asm worker. This will override the location specified by Core.setWorkerPath for Office worker files.
Parameters:
Name Type Description workerPath
string the prefix url for WebOfficeWorker.br.js.mem. -
<static> setOfficeResourcePath(workerPath)
-
Set the location of the Office resource worker. This will override the location specified by Core.setWorkerPath for Office worker files This new officeResourcePath will be used in very specific situations where worker files are located in different locations.
Parameters:
Name Type Description workerPath
string the prefix url for WebOfficeWorker.js and .mem files -
<static> setPDFAsmPath(workerPath)
-
Set the location of the PDF worker. This will override the location specified by Core.setWorkerPath for PDF worker files.
Parameters:
Name Type Description workerPath
string the prefix url for PDFNetC.gz.js. -
<static> setPDFResourcePath(resourcePath)
-
Set the location of PDF resources. This will override the location specified by Core.setWorkerPath for PDF resource files.
Parameters:
Name Type Description resourcePath
string the prefix url for PDFNetC.js.mem and PDFNet.res. -
<static> setPDFWorkerPath(workerPath)
-
Set the location of the PDF worker. This will override the location specified by Core.setWorkerPath for PDF worker files.
Parameters:
Name Type Description workerPath
string the prefix url for PDFworker.js -
<static> SetPreRenderLevel(level)
-
Set the pre-render level between 0 and 10, where 0 has pre-rendering and 10 has a lot of pre-rendering.
Parameters:
Name Type Description level
number The level to set -
<static> setProgressiveTime(milliseconds)
-
Control the time between progressive events when rendering a more complex page.
Parameters:
Name Type Description milliseconds
number the number of milliseconds between progressive events. By default this is disabled for XOD and 3 seconds (3000) otherwise. -
<static> setResourcesPath(path)
-
Sets the path to the resources folder.
Parameters:
Name Type Description path
string Path to the resources folder relative to the HTML file -
<static> setWorkerPath(path)
-
Sets the path to the Web Worker JavaScript file. By default the file is expected to be in the same directory as the html file of the viewer and the path should be specified relative to the html file
Parameters:
Name Type Description path
string Path to the Web Worker JS file relative to the html file of the viewer -
<static> syncNamespaces(namespaces)
-
Syncs the namespaces under the Core namespace attached to the window only.
This is required for interoperability between multiple instances of WebViewer since each loaded instance ends up with different class references despite sharing the same name.Parameters:
Name Type Description namespaces
object The object containing the namespaces that will be used. Properties
Name Type Argument Description PDFNet
object <optional>
The PDFNet namespace. This is probably the most common that needs to be synced. Actions
object <optional>
The Actions namespace. Annotations
object <optional>
The Annotations namespace. Math
object <optional>
The Math namespace. Tools
object <optional>
The Tools namespace. -
<static> unsetAsWindowsApp()
-
Unflag WebViewer as running inside a Windows App so that it doesn't automatically use the WinRTPartRetriever for loading local XOD files. This is unset by default.
-
<static> unsetCanvasMultiplier()
-
Unsets the multiplier that was set using the setCanvasMultiplier function. The multiplier will default back to the browser's devicePixelRatio
Type Definitions
-
CreateDocumentOptions
-
Create document options.
Properties:
Name Type Argument Description l
string <optional>
Same as licenseKey. licenseKey
string <optional>
The license key for viewing PDF or Office files (PDF/Office only). You only need to use one of 'l' or 'licenseKey'. docId
string <optional>
An unique identifier for the document, used for offline mode. onLoadingProgress
function <optional>
A callback function for loading progress, function signature function(percent) {}. onError
function <optional>
A callback function that will be called when error occurs in the process of creating a document. function signature function(e) {} workerTransportPromise
Promise.<any> <optional>
The workerTransportPromise that should be used to load the document. password
string | function <optional>
A password string or a function of the form function(callback) where callback is of the form function(password). This 'password' function will be called when a password is required to load a PDF document and should call the callback with the retrieved password. filename
string <optional>
A filename that is used for the downloaded file, and for determining the extension when options.extension isn't used. extension
string <optional>
Used for specifying the extension of the document to be loaded. This is necessary if the URL/path does not contain the file extension or if you're loading a Blob/File. customHeaders
object <optional>
An object containing custom HTTP headers to use when retrieving the document from the specified url. For example: {'Authorization' : 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='}. useDownloader
boolean <optional>
A boolean indicating whether Downloader should be used on urls (PDF only). https://www.pdftron.com/documentation/web/guides/usedownloader-option/. withCredentials
boolean <optional>
Whether to set the withCredentials property on the XMLHttpRequest. pageSizes
Array.<object> <optional>
An array of objects in the shape of { width: number, height: number }. Used to determine the page sizes when loading an image file. backendType
string <optional>
A string representing the "backend type" for rendering PDF documents. Pass "asm" to force the use of the ASM.js worker, "ems" to force the use of the WebAssembly worker (or ASM.js on non-wasm browsers) or "wasm-threads" to use threaded WebAssembly. xodOptions
object <optional>
An object that contains the options for a XOD document. Properties
Name Type Argument Description decrypt
boolean <optional>
Function to be called to decrypt a part of the XOD file. For default XOD AES encryption pass Core.Encryption.decrypt. decryptOptions
boolean <optional>
An object with options for the decryption e.g. {p: "pass", type: "aes"} where is p is the password. streaming
boolean <optional>
A boolean indicating whether to use http or streaming PartRetriever, it is recommended to keep streaming false for better performance. https://www.pdftron.com/documentation/web/guides/streaming-option. azureWorkaround
boolean <optional>
Whether or not to workaround the issue of Azure not accepting range requests of a certain type. Enabling the workaround will add an extra HTTP request of overhead but will still allow documents to be loaded from other locations. startOffline
boolean <optional>
Whether to start loading the document in offline mode or not. This can be set to true if the document had previously been saved to an offline database using WebViewer APIs. You'll need to use this option to load from a completely offline state. webviewerServerURL
string <optional>
A URL to the WebViewer server drop-in backend https://www.pdftron.com/documentation/web/guides/wv-server-deployment. fallbackToClientSide
boolean <optional>
A boolean indicating whether to fall back to client side rendering when WebViewer server fails cacheKey
string <optional>
A key that will be used for caching the document on WebViewer Server. forceClientSideInit
boolean <optional>
If set to true then when loading a document using WebViewer Server the document will always switch to client only rendering allowing page manipulation and the full API to be used. loadAsPDF
boolean <optional>
If set to true then this will convert any office file passed in into a PDF document customHandlerId
number <optional>
A field used to specify PDFTron custom security handler. Its value needs to be an integer in [0, 0xFFFFFFFF]. type
string <optional>
A custom document type. If set then the document type is not determined from the file extension. customDocParams
object <optional>
An object used to pass properties down to a custom document type. isRelativePath
boolean <optional>
If true, source will be considered as relative path/url. showInvalidBookmarks
boolean <optional>
If true, will retrieve invalid bookmarks officeOptions
object <optional>
An object that contains the options for an Office document. Properties
Name Type Argument Description templateValues
Core.TemplateData <optional>
If set, will perform template replacement with the data specified by this parameter doTemplatePrep
boolean <optional>
If set, it will interpret the office document as a template document and compile all of the template tags in the document disableBrowserFontSubstitution
boolean <optional>
By default, office viewing takes a lightweight approach to font substitution, allowing the browser to select fonts when they are not embedded in the document itself. While this means that WebViewer has access to all the fonts on the user's system, it also means that an office document may have a different "look" on different systems (depending on the fonts available) and when it is converted to PDF (as the PDF conversion routine cannot obtain low-level access to user fonts, for security reasons). disableBrowserFontSubstitution prevents this browser substitution, forcing the WebViewer backend to handle all fonts. This means that viewing and conversion to PDF will be 100% consistent from system-to-system, at the expense of a slightly slower initial viewing time and higher bandwidth usage. Using https://www.pdftron.com/documentation/web/faq/self-serve-substitute-fonts/ along with this option allows you to fully customize the substitution behaviour for all office files. formatOptions
object <optional>
An object that contains formatting options for an Office document. Same options as allowed here Core.PDFNet.Convert.OfficeToPDFOptions. Properties
Name Type Argument Description applyPageBreaksToSheet
boolean <optional>
If true will split Excel worksheets into pages so that the output resembles print output. displayChangeTracking
boolean <optional>
If true will display office change tracking markup present in the document (i.e, red strikethrough of deleted content and underlining of new content). Otherwise displays the resolved document content, with no markup. Defaults to true. excelDefaultCellBorderWidth
number <optional>
Cell border width for table cells that would normally be drawn with no border. In units of points. Can be used to achieve a similar effect to the "show gridlines" display option within Microsoft Excel. excelMaxAllowedCellCount
number <optional>
An exception will be thrown if the number of cells in an Excel document is above the value. Used for early termination of resource intensive documents. Setting this value to 250000 will allow the vast majority of Excel documents to convert without issue, while keeping RAM usage to a reasonable level. By default there is no limit to the number of allowed cells. locale
string <optional>
Sets the value for Locale in the options object ISO 639-1 code of the current system locale. For example: 'en-US', 'ar-SA', 'de-DE', etc. -
LoadDocumentOptions
-
Load document options.
Properties:
Name Type Argument Default Description loadAnnotations
boolean <optional>
true Whether to load document with or without annotations. l
string <optional>
Same as licenseKey. licenseKey
string <optional>
The license key for viewing PDF or Office files (PDF/Office only). You only need to use one of 'l' or 'licenseKey'. docId
string <optional>
An unique identifier for the document, used for offline mode. onLoadingProgress
function <optional>
A callback function for loading progress, function signature function(percent) {}. onError
function <optional>
A callback function that will be called when error occurs in the process of creating a document. function signature function(e) {} workerTransportPromise
Promise.<any> <optional>
The workerTransportPromise that should be used to load the document. password
string | function <optional>
A password string or a function of the form function(callback) where callback is of the form function(password). This 'password' function will be called when a password is required to load a PDF document and should call the callback with the retrieved password. filename
string <optional>
A filename that is used for the downloaded file, and for determining the extension when options.extension isn't used. extension
string <optional>
Used for specifying the extension of the document to be loaded. This is necessary if the URL/path does not contain the file extension or if you're loading a Blob/File. customHeaders
object <optional>
An object containing custom HTTP headers to use when retrieving the document from the specified url. For example: {'Authorization' : 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='}. useDownloader
boolean <optional>
A boolean indicating whether Downloader should be used on urls (PDF only). https://www.pdftron.com/documentation/web/guides/usedownloader-option/. withCredentials
boolean <optional>
Whether to set the withCredentials property on the XMLHttpRequest. pageSizes
Array.<object> <optional>
An array of objects in the shape of { width: number, height: number }. Used to determine the page sizes when loading an image file. backendType
string <optional>
A string representing the "backend type" for rendering PDF documents. Pass "asm" to force the use of the ASM.js worker, "ems" to force the use of the WebAssembly worker (or ASM.js on non-wasm browsers) or "wasm-threads" to use threaded WebAssembly. xodOptions
object <optional>
An object that contains the options for a XOD document. Properties
Name Type Argument Description decrypt
boolean <optional>
Function to be called to decrypt a part of the XOD file. For default XOD AES encryption pass Core.Encryption.decrypt. decryptOptions
boolean <optional>
An object with options for the decryption e.g. {p: "pass", type: "aes"} where is p is the password. streaming
boolean <optional>
A boolean indicating whether to use http or streaming PartRetriever, it is recommended to keep streaming false for better performance. https://www.pdftron.com/documentation/web/guides/streaming-option. azureWorkaround
boolean <optional>
Whether or not to workaround the issue of Azure not accepting range requests of a certain type. Enabling the workaround will add an extra HTTP request of overhead but will still allow documents to be loaded from other locations. startOffline
boolean <optional>
Whether to start loading the document in offline mode or not. This can be set to true if the document had previously been saved to an offline database using WebViewer APIs. You'll need to use this option to load from a completely offline state. webviewerServerURL
string <optional>
A URL to the WebViewer server drop-in backend https://www.pdftron.com/documentation/web/guides/wv-server-deployment. fallbackToClientSide
boolean <optional>
A boolean indicating whether to fall back to client side rendering when WebViewer server fails cacheKey
string <optional>
A key that will be used for caching the document on WebViewer Server. forceClientSideInit
boolean <optional>
If set to true then when loading a document using WebViewer Server the document will always switch to client only rendering allowing page manipulation and the full API to be used. loadAsPDF
boolean <optional>
If set to true then this will convert any office file passed in into a PDF document customHandlerId
number <optional>
A field used to specify PDFTron custom security handler. Its value needs to be an integer in [0, 0xFFFFFFFF]. type
string <optional>
A custom document type. If set then the document type is not determined from the file extension. customDocParams
object <optional>
An object used to pass properties down to a custom document type. isRelativePath
boolean <optional>
If true, source will be considered as relative path/url. showInvalidBookmarks
boolean <optional>
If true, will retrieve invalid bookmarks officeOptions
object <optional>
An object that contains the options for an Office document. Properties
Name Type Argument Description templateValues
Core.TemplateData <optional>
If set, will perform template replacement with the data specified by this parameter doTemplatePrep
boolean <optional>
If set, it will interpret the office document as a template document and compile all of the template tags in the document disableBrowserFontSubstitution
boolean <optional>
By default, office viewing takes a lightweight approach to font substitution, allowing the browser to select fonts when they are not embedded in the document itself. While this means that WebViewer has access to all the fonts on the user's system, it also means that an office document may have a different "look" on different systems (depending on the fonts available) and when it is converted to PDF (as the PDF conversion routine cannot obtain low-level access to user fonts, for security reasons). disableBrowserFontSubstitution prevents this browser substitution, forcing the WebViewer backend to handle all fonts. This means that viewing and conversion to PDF will be 100% consistent from system-to-system, at the expense of a slightly slower initial viewing time and higher bandwidth usage. Using https://www.pdftron.com/documentation/web/faq/self-serve-substitute-fonts/ along with this option allows you to fully customize the substitution behaviour for all office files. formatOptions
object <optional>
An object that contains formatting options for an Office document. Same options as allowed here Core.PDFNet.Convert.OfficeToPDFOptions. Properties
Name Type Argument Description applyPageBreaksToSheet
boolean <optional>
If true will split Excel worksheets into pages so that the output resembles print output. displayChangeTracking
boolean <optional>
If true will display office change tracking markup present in the document (i.e, red strikethrough of deleted content and underlining of new content). Otherwise displays the resolved document content, with no markup. Defaults to true. excelDefaultCellBorderWidth
number <optional>
Cell border width for table cells that would normally be drawn with no border. In units of points. Can be used to achieve a similar effect to the "show gridlines" display option within Microsoft Excel. excelMaxAllowedCellCount
number <optional>
An exception will be thrown if the number of cells in an Excel document is above the value. Used for early termination of resource intensive documents. Setting this value to 250000 will allow the vast majority of Excel documents to convert without issue, while keeping RAM usage to a reasonable level. By default there is no limit to the number of allowed cells. locale
string <optional>
Sets the value for Locale in the options object ISO 639-1 code of the current system locale. For example: 'en-US', 'ar-SA', 'de-DE', etc. -
onDateSelected(date)
-
Callback function for when a date is selected
Parameters:
Name Type Description date
string selected Date -
TemplateBoundingBox
-
A bounding box of template tag text or template inserted content.
Type:
- object
Properties:
Name Type Description pageNum
number The page index (1-based indexing) this bounding box appears on. box
Core.Math.Rect The bounding box, units are points. -
TemplateBoundingBoxes
-
A dictionary mapping template keys to bounding boxes of either template tags or template inserted content. The template engine tries to infer the scope of the template that are used in loops. Loop keys will be scoped in this dictionary with the '::' separator, like this:
Type:
- object.<string, Array.<Core.TemplateBoundingBox>>
- See:
-
- https://www.pdftron.com/documentation/windows/guides/generate-via-template/advanced/#explicit-loop-scope for more information on loop scoping.
Example
'loop_var_1::loop_var_2 ... ::item_var'
-
TemplateData
-
Office template data (input supplied to applyTemplateValues).
Type:
- See:
-
- https://www.pdftron.com/documentation/core/guides/generate-via-template/data-model/ for a detailed specification of the template format and supported features.
-
TemplateDataContent
-
A replacement value for a simple data tag, @example '{{tag}}'
Type:
-
TemplateDataImage
-
A bitmap image. All parameters are required. The image will be resized to the requested width and height on the page, which may change it's aspect ratio.
Properties:
Name Type Description image_url
string URL to download image from. width
number The image width, measure in points. height
number The image height, measured in points. -
TemplateDataKeyValues
-
A dictionary of template keys and their replacement values.
Type:
- object.<string, Core.TemplateDataValue>
-
TemplateDataLoop
-
The argument to a template loop: an array which will be looped over.
Type:
- Array.<Core.TemplateDataKeyValues>
-
TemplateDataText
-
A text replacement value.
Type:
-
TemplateDataTextExplicit
-
Simple text, equivalent to just passing a string.
Properties:
Name Type Description text
string -
TemplateDataTextLines
-
An array of text which will separated by line breaks.
Properties:
Name Type Description text_lines
Array.<string> -
TemplateDataValue
-
A replacement value for a tag.
Type:
-
TemplateSchema
-
Office template schema (output returned from getTemplateKeys with format: schema).
Type:
- object
- See:
-
- https://www.pdftron.com/documentation/core/guides/generate-via-template/data-model/ for a detailed specification of the template format and supported features.
Properties:
Name Type Description keys
Core.TemplateSchemaKeyValues The top-level template keys in the document. -
TemplateSchemaBool
-
This indicates all usages of the key are used in a conditional. The key is not restricted to a boolean and can take data in the form of content such as a string, but that string would not be rendered anywhere in the document.
Type:
- object
Properties:
Name Type Description typeId
'TemplateSchemaBool' docOrder
number An index representing this template key's first occurrence in the natural flow order of the document's keys (left-to-right, top-to-bottom). -
TemplateSchemaContent
-
This indicates there is a template tag for this key that will be replaced with content, such as text or an image.
Type:
- object
Properties:
Name Type Description typeId
'TemplateSchemaContent' docOrder
number An index representing this template key's first occurrence in the natural flow order of the document's keys (left-to-right, top-to-bottom). -
TemplateSchemaKeyValues
-
A dictionary of template keys and their expected data types.
Type:
- object.<string, Core.TemplateSchemaValue>
-
TemplateSchemaLoop
-
This indicates the key is a loop. Since a key may be reused in multiple loops, the loopType property is an array.
Type:
- object
Properties:
Name Type Description typeId
'TemplateSchemaLoop' docOrder
number An index representing this template key's first occurrence in the natural flow order of the document's keys (left-to-right, top-to-bottom). itemSchema
Core.TemplateSchemaKeyValues The sub-schema for this loop. Template keys that are used within the loop will appear here. Note that if multiple loops with the same key have different inner keys, the item schema will contain the union of all inner key usages. loopType
Array.<('tableRow'|'orderedList'|'unorderedList'|'other')> Array of the loop types, ordered by their document ordering. -
TemplateSchemaObject
-
This indicates the key is used as an object in a tag dot expression.
Type:
- object
Properties:
Name Type Description typeId
'TemplateSchemaObject' docOrder
number An index representing this template key's first occurrence in the natural flow order of the document's keys (left-to-right, top-to-bottom). properties
Core.TemplateSchemaKeyValues The sub-schema for all properties of this object. The properties are gathered from the right-hand-side of all usages of this object in dot expressions. Example
'obj' in the tag '{{obj.prop}}'
-
TemplateSchemaValue
-
The expected type of input data for a template tag. The type can be read from the typeId property.
Type:
- Core.TemplateSchemaContent | Core.TemplateSchemaBool | Core.TemplateSchemaLoop | Core.TemplateSchemaObject