UNPKG

@pdftron/webviewer-html

Version:

This is an addon for WebViewer that allows loading HTML web pages so that they can be annotated.

1,350 lines (485 loc) 19.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Documentation Module: @pdftron/webviewer-html</title> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> <link type="text/css" rel="stylesheet" href="styles/site.simplex.css"> </head> <body> <div class="navbar navbar-default navbar-fixed-top "> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="index.html">Documentation</a> <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="navbar-collapse collapse" id="topNavigation"> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a> <ul class="dropdown-menu "> <li><a href="module-@pdftron_webviewer-html.html">@pdftron/webviewer-html</a></li> </ul> </li> <li class="dropdown"> <a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a> <ul class="dropdown-menu "> <li><a href="module-@pdftron_webviewer-html.html#~event:proxyLoaded">event:proxyLoaded</a></li> </ul> </li> </ul> <div class="col-sm-3 col-md-3"> <form class="navbar-form" role="search"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="q" id="search-input"> <div class="input-group-btn"> <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button> </div> </div> </form> </div> </div> </div> </div> <div class="container" id="toc-content"> <div class="row"> <div class="col-md-8"> <div id="main"> <h1 class="page-title">Module: @pdftron/webviewer-html</h1> <section> <header> </header> <article> <div class="container-overview"> <div class="description"><p>This is an addon for WebViewer that allows loading HTML web pages so that HTML pages can be annotated. See the npm package on <a href="https://www.npmjs.com/package/@pdftron/webviewer-html">@pdftron/webviewer-html</a> for more information.</p></div> <dl class="details"> </dl> </div> <h3 class="subsection-title">Methods</h3> <dl> <hr> <dt> <h4 class="name" id=".initializeHTMLViewer"><span class="type-signature">&lt;async, static> </span>initializeHTMLViewer(instance [, options])</h4> </dt> <dd> <div class="description"> <p>Initializes the HTML viewer so that webviewer can load HTMLs.</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>instance</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last"><p>The WebViewer instance</p></td> </tr> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"><p>The options objects containing license.</p> <h6 class="method-params-label method-subparams-label">Properties</h6> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>license</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"><p>A string containing a license key for WebViewer HTML Addon to remove the watermark.</p></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>A promise that resolves to an object containing the functions needed to load HTML in WebViewer.</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">HTMLFunctions</span> </dd> </dl> </dd> </dl> <h3 class="subsection-title">Type Definitions</h3> <dl> <hr> <dt class="name" id="~HTMLFunctions"> <h4 id="~HTMLFunctions">HTMLFunctions</h4> </dt> <dd> <h5>Type:</h5> <ul> <li> <span class="param-type">Object</span> </li> </ul> <dl class="details"> <h5 class="subsection-title">Properties:</h5> <dl> <table class="props table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>loadHTMLPage</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><p>Loads an HTML page for the WebViewer instance passed into initializeHTMLViewer.</p></td> </tr> <tr> <td class="name"><code>setInstance</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><p>Sets the WebViewer instance. Must be called if instance is not passed into initializeHTMLViewer</p></td> </tr> </tbody> </table> </dl> </dl> </dd> <hr> <dt> <h4 class="name" id="~loadHTMLPage"><span class="type-signature"></span>loadHTMLPage(options)</h4> </dt> <dd> <div class="description"> <p>Loads an HTML page for the WebViewer instance passed into initializeHTMLViewer.</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>The options objects containing page iframeUrl, width, height and urlToProxy.</p> <h6 class="method-params-label method-subparams-label">Properties</h6> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>iframeUrl</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last"><p>URL of the page being displayed in webviewer. This should be the url of the proxy server.</p></td> </tr> <tr> <td class="name"><code>width</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last"><p>Width for the page to be loaded at.</p></td> </tr> <tr> <td class="name"><code>height</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last"><p>Height for the page to be loaded at.</p></td> </tr> <tr> <td class="name"><code>urlToProxy</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last"><p>Original URL of the page you are trying to load and that is being proxied by the server.</p></td> </tr> <tr> <td class="name"><code>scrollable</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"><p>Boolean containing value for whether or not page should be scrolled.</p></td> </tr> <tr> <td class="name"><code>disableLinkAnnotations</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"><p>Boolean containing value for disabling link annotations.</p></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">void</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">WebViewer( { path: &#x27;lib&#x27;, }, document.getElementById(&#x27;viewer&#x27;) ).then(async (instance) =&gt; { // 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: &#x27;http://localhost:3100/&#x27;, // Original url that is being proxied urlToProxy: &#x27;https://www.pdftron.com/&#x27;, width: 500, height: 500, }); });</pre> </dd> <hr> <dt> <h4 class="name" id="~setInstance"><span class="type-signature"></span>setInstance(instance)</h4> </dt> <dd> <div class="description"> <p>Sets the WebViewer instance. Must be called if instance is not passed into initializeHTMLViewer</p> </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>instance</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>The WebViewer instance.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">void</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">WebViewer( { path: &#x27;lib&#x27;, }, document.getElementById(&#x27;viewer&#x27;) ).then(async (instance) =&gt; { // Extends WebViewer to allow loading HTML5 files from URL or static folder. const { loadHTMLPage, setInstance } = await initializeHTMLViewer(instance, { license }); // OR // setInstance(instance); });</pre> </dd> </dl> <h3 class="subsection-title">Events</h3> <dl> <hr> <dt> <h4 class="name" id="~event:proxyLoaded">proxyLoaded</h4> </dt> <dd> <div class="description"> <p>Event emitted when the proxy iframe finishes loading. This event comes from the DOMContentLoaded event attached to the proxy website.</p> </div> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">WebViewer(...) .then((instance) =&gt; { const { docViewer } = instance; docViewer.addEventListener(&#x27;proxyLoaded&#x27;, listener); });</pre> </dd> </dl> </article> </section> </div> </div> <div class="clearfix"></div> <div class="col-md-3"> <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div> </div> </div> </div> <div class="modal fade" id="searchResults"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">Search results</h4> </div> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <footer> <span class="jsdoc-message"> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on 2023-06-02T16:25:07-07:00 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. </span> </footer> <script src="scripts/docstrap.lib.js"></script> <script src="scripts/toc.js"></script> <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script> <script> $( function () { $( "[id*='$']" ).each( function () { var $this = $( this ); $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) ); } ); $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () { var $this = $( this ); var example = $this.find( "code" ); exampleText = example.html(); var lang = /{@lang (.*?)}/.exec( exampleText ); if ( lang && lang[1] ) { exampleText = exampleText.replace( lang[0], "" ); example.html( exampleText ); lang = lang[1]; } else { var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/); lang = langClassMatch ? langClassMatch[1] : "javascript"; } if ( lang ) { $this .addClass( "sunlight-highlight-" + lang ) .addClass( "linenums" ) .html( example.html() ); } } ); Sunlight.highlightAll( { lineNumbers : false, showMenu : true, enableDoclinks : true } ); $.catchAnchorLinks( { navbarOffset: 10 } ); $( "#toc" ).toc( { anchorName : function ( i, heading, prefix ) { return $( heading ).attr( "id" ) || ( prefix + i ); }, selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4", showAndHide : false, smoothScrolling: true } ); $( "#main span[id^='toc']" ).addClass( "toc-shim" ); $( '.dropdown-toggle' ).dropdown(); $( "table" ).each( function () { var $this = $( this ); $this.addClass('table'); } ); } ); </script> <!--Navigation and Symbol Display--> <!--Google Analytics--> <script type="text/javascript"> $(document).ready(function() { SearcherDisplay.init(); }); </script> </body> </html>