This is an addon for WebViewer that allows loading HTML web pages so that HTML pages can be annotated. See the npm package on @pdftron/webviewer-html for more information.
Methods
-
<async, static> initializeHTMLViewer(instance [, options])
-
Initializes the HTML viewer so that webviewer can load HTMLs.
Parameters:
Name Type Argument Description instanceObject The WebViewer instance
optionsObject <optional>
The options objects containing license.
Properties
Name Type Argument Description licensestring <optional>
A string containing a license key for WebViewer HTML Addon to remove the watermark.
Returns:
A promise that resolves to an object containing the functions needed to load HTML in WebViewer.
- Type
- HTMLFunctions
Type Definitions
-
HTMLFunctions
-
Type:
- Object
Properties:
Name Type Description loadHTMLPagefunction Loads an HTML page for the WebViewer instance passed into initializeHTMLViewer.
setInstancefunction Sets the WebViewer instance. Must be called if instance is not passed into initializeHTMLViewer
-
loadHTMLPage(options)
-
Loads an HTML page for the WebViewer instance passed into initializeHTMLViewer.
Parameters:
Name Type Description optionsObject The options objects containing page iframeUrl, width, height and urlToProxy.
Properties
Name Type Argument Description iframeUrlstring URL of the page being displayed in webviewer. This should be the url of the proxy server.
widthnumber Width for the page to be loaded at.
heightnumber Height for the page to be loaded at.
urlToProxystring Original URL of the page you are trying to load and that is being proxied by the server.
scrollableboolean <optional>
Boolean containing value for whether or not page should be scrolled.
disableLinkAnnotationsboolean <optional>
Boolean containing value for disabling link annotations.
Returns:
- Type
- void
Example
WebViewer( { path: 'lib', }, document.getElementById('viewer') ).then(async (instance) => { // Extends WebViewer to allow loading HTML5 files from URL or static folder. const { loadHTMLPage } = await initializeHTMLViewer(instance, { license }); loadHTMLPage({ // Your webviewer-html-proxy-server url iframeUrl: 'http://localhost:3100/', // Original url that is being proxied urlToProxy: 'https://www.pdftron.com/', width: 500, height: 500, }); }); -
setInstance(instance)
-
Sets the WebViewer instance. Must be called if instance is not passed into initializeHTMLViewer
Parameters:
Name Type Description instanceObject The WebViewer instance.
Returns:
- Type
- void
Example
WebViewer( { path: 'lib', }, document.getElementById('viewer') ).then(async (instance) => { // Extends WebViewer to allow loading HTML5 files from URL or static folder. const { loadHTMLPage, setInstance } = await initializeHTMLViewer(instance, { license }); // OR // setInstance(instance); });
Events
-
proxyLoaded
-
Event emitted when the proxy iframe finishes loading. This event comes from the DOMContentLoaded event attached to the proxy website.
Example
WebViewer(...) .then((instance) => { const { docViewer } = instance; docViewer.addEventListener('proxyLoaded', listener); });