Namespace: CoreControls

CoreControls

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

Examples

// 5.1 and after
WebViewer(...)
  .then(function(instance) {
    var CoreControls = instance.CoreControls;
    // CoreControls.someAPI();
  });
// 4.0 ~ 5.0
var viewerElement = document.getElementById('viewer');
var viewer = new PDFTron.WebViewer(...);

viewerElement.addEventListener('ready', function() {
  var viewerIframe = document.querySelector('iframe');
  var CoreControls = viewerIframe.contentWindow.CoreControls;
  // CoreControls.someAPI();
});

Classes

AnnotationManager
BlackBoxAnnotationManager
Bookmark
DisplayMode
DisplayModeManager
Document
DocumentViewer

Members


<static> CanvasMode

Canvas mode enumeration, has values of PageCanvas (default) and ViewportCanvas

Properties:
Name Type Description
ViewportCanvas string
PageCanvas string

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

Methods


<static> BaseDocument()

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


<static> disableEmbeddedJavaScript()

Disables the execution of embedded JavaScript


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

Enable or disable using PNaCl subzero compiler. With subzero enabled the first load and execution is significantly faster at the expense of slightly slower execution (about 10%) for subsequent usage. Note that subzero is only consistently available on Chrome 56 or above (and is on by default on Chrome 56+) so this function call will be ignored on earlier Chrome versions and other browsers.

Parameters:
Name Type Description
value boolean

If true and subzero is supported by the browser it will be enabled.


<static> forceBackendType()

Set default backend type. This method can be used for forced backend type for specific workers, for example, "ems" for Emscripten worker type

Returns:

backendType value for default backed type, e.g. pnacl, ems, jsworker.

Type
string

<static> getCurrentPDFBackendType()

Gets the current backend type loaded or being loaded

Returns:

Returns "pnacl" is PNaCl is being used, "ems" if Emscripten is being used

Type
Promise.<string>

<static> getCurrentPDFBackendType()

Gets the current backend type being used.

Returns:

Returns "pnacl" is PNaCl is being used, "ems" if Emscripten is being used and undefined if nothing is being used yet

Type
string

<static> getDefaultBackendType()

Gets the default pdf backend type that should be used for this browser.

Returns:

Returns "pnacl" is PNaCl should be used and "ems" if Emscripten should be used

Type
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> 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, ResizableWorker.js, .nmf and .pexe files.

Type
string

<static> getResourcesPath()

Gets the path to the resources folder

Returns:

The path to the resources folder

Type
string

<static> getWorkerPath()

Gets the path to the Web Worker JavaScript file

Returns:

The path to the worker

Type
string

<static> initPDFWorkerTransports(pdfBackendType, workerHandlers, l)

Begins setup of PDF Worker Object.

Parameters:
Name Type Description
pdfBackendType string

object representing an PDF backend type ("pnacl" or "ems")

workerHandlers object

object holding event and error handlers for the worker (workerLoadingProgress, pnaclCrashError, pnaclLoadError, 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> isSubzeroEnabled()

Returns whether PNaCl subzero is supported by the browser and enabled.

Returns:

returns true if subzero is supported and enabled and false otherwise.

Type
boolean

<static> preloadPDFWorker(pdfBackendType, workerHandlers, options)

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 an PDF backend type ("pnacl" or "ems")

workerHandlers object

object holding event and error handlers for the worker (workerLoadingProgress).

options object

An object with the following optional values: useEmscriptenWhileLoading If the backend type is set to pnacl then this determines whether emscripten should be used if PNaCl needs time to set up.

Returns:

The worker object

Type
object

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

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> SetCanvasMode(mode)

Sets the canvas rendering mode.

Parameters:
Name Type Description
mode CoreControls.CanvasMode

The canvas mode to switch to


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

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.


<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, ResizableWorker.js, .nmf and .pexe files.


<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, 1 second (1000) for PNaCl and 3 seconds (3000) for Emscripten.


<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