Methods
-
getInstance( [element])
-
Gets an already existing instance of WebViewer. If only one instance of WebViewer exists on the page, then 'element' is not required, and the function will return the instance of WebViewer. If more than one instance of WebViewer exists, you must pass in the DOM element containing the instance of WebViewer you want to retrieve. This function can be imported directly as a module as well.
Parameters:
Name Type Argument Description elementHTMLElement <optional>
The DOM element containing the instance of WebViewer you want to retrieve Returns:
Returns an instance of WebViewer. Returns null if no instances are available.- Type
- WebViewerInstance
Example
import { getInstance } from '@pdftron/webviewer' // After WebViewer has already been constructed const instance = getInstance(); -
WebViewer(options, viewerElement)
-
A function that creates an instance of WebViewer, and embeds it on the HTML page
Parameters:
Name Type Description optionsWebViewerOptions viewerElementHTMLElement Returns:
A promise resolved with WebViewer instance.- Type
- Promise.<WebViewerInstance>
Example
WebViewer({ licenseKey: 'Insert commercial license key here after purchase' }, document.getElementById('viewer')) .then(function(instance) { const documentViewer = instance.Core.documentViewer; const annotationManager = instance.Core.annotationManager; // call methods from instance, documentViewer and annotationManager as needed // you can also access major namespaces from the instances as follows: // const Tools = instance.Core.Tools; // const Annotations = instance.Core.Annotations; });
Type Definitions
-
LayerContext
-
Type:
- object
Properties:
Name Type Description objstring the unique identifier of the layer. This is not defined if the layer is a label namestring the name of the layer. It does not have not be unique lockedboolean boolean to denote if the layer is locked for viewing. This state cannot be toggled by the user through the user interface visibleboolean boolean to denote if the layer is visible childrenArray.<LayerContext> the layer's children (if any). This is not defined if the layer is a label. -
LeaderPoints
-
the point in viewer coordinates
Type:
- Object
Properties:
Name Type Description StartCore.Math.Point the start point EndCore.Math.Point the end point -
onDateSelected(date)
-
Callback function for when a date is selected
Parameters:
Name Type Description datestring selected Date -
PageManipulationSection
-
Type:
- object
Properties:
Name Type Description typestring Required type of 'customPageOperation' headerstring Header to be displayed in the UI for this section dataElementstring Unique dataElement operationsArray.<PageOperation> the operations that will be available under this section -
PageOperation
-
Type:
- object
Properties:
Name Type Description titlestring Title to be displayed for the operation imgstring path to imge to be used as an icon for the operation onClickfunction onClick handler, which takes as a parameter an array of selected page numbers dataElementstring Unique dataElement for this operation -
WebViewerOptions
-
Type:
- Object
Properties:
Name Type Argument Default Description pathstring Path to the WebViewer lib folder annotationUserstring <optional>
Guest Name of the user for annotations configstring <optional>
URL path to a custom JavaScript for customizations cssstring <optional>
URL path to a custom CSS file for customizations disabledElementsArray.<string> <optional>
List of data-elements to be disabled in UI accessibleModeboolean <optional>
false Enable accessibility features. E.g tab page selection and page text in the DOM enableAnnotationsboolean <optional>
true Enable annotations feature enableFilePickerboolean <optional>
false Enable file picker feature enableMeasurementboolean <optional>
false Enable measurement tools enableRedactionboolean <optional>
false Enable redaction tool extensionstring <optional>
Extension of the document to be loaded filenamestring <optional>
The name of the file that will be used when downloading the document. The extension in the filename will be used as the document type to be loaded (e.g. myfile.docx will treat the file as docx) if no extension option is passed. initialDocstring <optional>
URL path to a document to load on startup isAdminUserboolean <optional>
false Set user permission to admin isReadOnlyboolean <optional>
false Set user permission to read-only licenseKeystring <optional>
License key for viewing documents. If not set then WebViewer will be in demo mode. uistring <optional>
default Type of UI to be used. Accepts `default`|`beta`. disableLogsboolean <optional>
false Disables console logs coming from WebViewer, including the version and build numbers disableFlattenedAnnotationsboolean <optional>
false Disables the flattened rendering of existing annotations in documents. uiPathstring <optional>
Path to UI folder to use a different UI or customized UI. Default is'./ui/index.html'. selectAnnotationOnCreationboolean <optional>
false If true then newly added annotations will be selected automatically highContrastModeboolean <optional>
false If true then the UI will use high constrast colours to help with accessibility.