Best way to asynchronously update initialized WebViewer instance?

206 views
Skip to first unread message

Tim McElwee

unread,
Jun 27, 2017, 3:03:25 PM6/27/17
to PDFTron PDFNet SDK
I'm just getting started digging into using the WebViewer in our Angular 2 SPA. I've been digging through the examples and I don't see an example of asynchronously updating the initialized instance of a WebViewer. Am I just missing this? Can someone point me in the right direction?

Currently, I have change detection setup to initialize the viewer. Works great on the first change, but not on subsequent clicks. I don't really want to have to destroy the current instance and take the hit of building the viewer again with each new document. I'd really like to get a seamless experience when the user moves to the next document in the list.

Thanks in advance if you can offer any help.

Ryan - PDFNet Developer

unread,
Jun 29, 2017, 12:34:38 PM6/29/17
to PDFTron WebViewer
Posting on behalf of another customer.

I use the WebViewer in an Ionic 2 app (which uses Angular 2).  I only build the WebViewer once and then load subsequent documents with code like this:

self.webViewer.loadDocument(sourceUri, { customHeaders: headers });

When I initially setup the WebViewer instance I hook into the documentLoaded event in order to load annotations etc. for each document after it is loaded into the viewer:

viewerElement.bind('documentLoaded', function (event, data) {

Tim McElwee

unread,
Jul 20, 2017, 5:33:12 PM7/20/17
to PDFTron WebViewer
Great. Thanks for the reply, Ryan!
Reply all
Reply to author
Forward
0 new messages