WebViewer
WebViewer is a pure JavaScript library to annotate, view, and edit documents inside all major browsers.
Instantiation
You must instantiate WebViewer in order to access classes and APIs.
// 5.1 and after
WebViewer({
licenseKey: 'YOUR_LICENSE_KEY'
}, document.getElementById('viewer'))
.then(function(instance) {
var docViewer = instance.docViewer;
var annotManager = instance.annotManager;
// call methods from instance, docViewer and annotManager as needed
// you can also access major namespaces from the instancs as follows:
// var Tools = instance.Tools;
// var Annotations = instance.Annotations;
});
// 4.0 ~ 5.0
var viewerElement = document.getElementById('viewer');
var viewer = new PDFTron.WebViewer({
l: 'YOUR_LICENSE_KEY'
}, viewerElement);
viewerElement.addEventListener('ready', function() {
var instance = viewer.getInstance();
var docViewer = instance.docViewer;
var annotManager = docViewer.getAnnotationManager();
// call methods from instance, docViewer and annotManager as needed
// you can also access major namespaces from the iframe window as follows:
// var iframeWindow = document.querySelector('iframe').contentWindow;
// var Tools = iframeWindow.Tools;
// var Annotations = iframeWindow.Annotations;
});
See WebViewer for details.
Frequently used namespaces/classes
- WebViewer - Main class.
- DocumentViewer - A control class used for document viewing and operations.
- AnnotationManager - A control class used for annotation managing.
- Document - A class representing a document.
- Annotations - A namespace containing annotation classes.
- Tools - A namespace containing tool classes.
- CoreControls - A namespace containing core control classes.
- PDFNet - A namespace containing PDFNet classes (used in fullAPI option).