Namespace: CoreControls

CoreControls

The namespace containing WebViewer's core user controls, including DocumentViewer control and the Document class.

Classes

AnnotationHistoryManager
AnnotationManager
BlackBoxAnnotationManager
Bookmark
DisplayMode
DisplayModeManager
Document
DocumentViewer
EditBoxManager
WidgetEditingManager

Namespaces

Math
Search

Members


<static> DisplayModes

Display modes that control how the document's page are displayed
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> 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> MarkedStates

Represents the different Marked state values that you can apply to annotation status.
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.
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.
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> StateModel

Represents the different state models that you can apply to annotation.
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

Methods


<static> BaseDocument()

BaseDocument is used to alert if a Document implementation is not following the Document interface.

<static> createDocument(source [, options])

Creates an initialized CoreControls.Document instance.
Parameters:
Name Type Argument Description
source string | File | ArrayBuffer | Blob | PDFNet.PDFDoc Source parameter, path/url to document or File.
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Description
l string <optional>
The license key for viewing PDF or Office files (PDF/Office only). You only need to use one of 'l' or '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 "ems" to force the use of the ASM.js/WebAssembly worker 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 CoreControls.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.
pdftronServer 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
type string <optional>
A custom document type. If set then the document type is not determined from the file extension.
Returns:
Promise that resolves when doc.loadAsync has been successfully called and returns CoreControls.Document instance.
Type
Promise.<CoreControls.Document>

<static> disableEmbeddedJavaScript()

Disables the execution of embedded JavaScript

<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> enableFullPDF(value)

Enable or disable use of the full version of PDFNetJS.
Parameters:
Name Type Description
value boolean Whether to enable or disable the full version of PDFNetJS

<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 backed type, e.g. ems, wasm-threads, jsworker.

<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> getCurrentOfficeBackendType()

Gets the current backend type being used.
Returns:
Returns "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 "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 "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> getExternalPath()

Get the location of external scripts.
Returns:
the prefix url external scripts.
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 and ResizableWorker.js
Type
string

<static> getResourcesPath()

Gets the path to the resources folder
Returns:
The path to the resources folder
Type
string

<static> getVersion()

Returns the WebViewer version.
Returns:
WebViewer version
Type
string

<static> getWorkerPath()

Gets the path to the Web Worker JavaScript file
Returns:
The path to the worker
Type
string

<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 ("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> isDemoMode()

Returns whether demo mode is active or not. Must be called after the document is loaded or after the call to CoreControls.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.
Returns:
A promise that resolves to an ArrayBuffer containing the resulting PDF data.
Type
ArrayBuffer

<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 ("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 ("ems" or "wasm-threads")
workerHandlers object object holding event and error handlers for the worker (workerLoadingProgress).
Returns:
The worker object
Type
object

<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> SetCachingLevel(level)

Set the caching level between 0 and 10, where 0 is no caching and 10 uses a very large cache
Parameters:
Name Type Description
level number The level to 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> 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 Description
workerPath string The path to the local worker files
isExact boolean 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 CoreControls.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 CoreControls.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 CoreControls.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 CoreControls.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 CoreControls.setWorkerPath for PDF worker files.
Parameters:
Name Type Description
workerPath string the prefix url for PDFworker.js and ResizableWorker.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

getBlackBoxAnnotationManager()

Gets an instance of BlackBoxAnnotationManager
Returns:
Resolves with a new instance of BlackBoxAnnotationManager
Type
Promise.<CoreControls.BlackBoxAnnotationManager>