Frameworks
Integrations
Mendix
SharePoint
Default UI
Modular UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
When you download the WebViewer package, it contains three main components:
webviewer.js
is the main entry point of this package that uses UI and Core namespaces to render the WebViewer app inside an iframe or a web component. So, after importing webviewer.js
, the WebViewer app (composed of UI and Core) can be instantiated by using the PDFTron.WebViewer constructor. If you look at the viewing sample, you will see that the app is created inside an iframe.
The instantiation can be summarized in one sentence.
Instantiation === Webviewer creating the iframe-wrapped app based on the options
For example, for this code:
the following steps will be executed:
webviewer.js
the path
to load the library files containing the UI and CoreviewerElement
providedinitialDoc
option and calls the loadDocument
function from CoremyDoc.pdf
document and renders it in the UIWebViewer also has other constructor options for configuring the viewer.
It's important to remember that WebViewer's iframe is a completely separate window, isolated from your own HTML page. This means all WebViewer objects and namespaces are only available in the iframe. Then how do you access objects inside the iframe to call functions or to listen to events? You can do that with the instance
that's returned from the constructor's promise.
The instance
argument that's returned from the promise is an object that contains objects and namespaces from the iframe as well as helpful APIs. So you can:
instance.Core.documentViewer.addEventListener('documentLoaded', documentLoadedHandler)
to run functions when a document is loadedinstance.Core.Annotations
to see different annotations classes availableinstance.UI.setCurrentPageNumber(5)
to navigate the viewer to page 5.Refer to our Usage guide or WebViewer class API for more details.
In some scenarios, it may be necessary to put the WebViewer library files on a different domain. Although this is completely possible, it does change the WebViewer iframe source to point to another domain and with this, comes with additional considerations.
Check out the following guide for more details!
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales