ReaderControl.unload issue

157 views
Skip to first unread message

Michael Dudek

unread,
May 2, 2014, 7:33:23 AM5/2/14
to pdfnet-w...@googlegroups.com
Hello,
I'm closing document using ReaderControl.unload(), but I have found that its called $("body").unbind() in this method. It unregisters all my existing event handlers on body element, so its not friendly to other components in page.  Is it possible to fix this issue please?

Thanks
Best regards
Michael Dudek

Matt Parizeau

unread,
May 5, 2014, 1:25:46 PM5/5/14
to pdfnet-w...@googlegroups.com
Hi Michael,

I'm assuming you're referring to DocumentViewer's Dispose function. That function just calls Document's UnloadResources function and then unbind on the body. So instead of calling Dispose you could just do:
myDocViewer.GetDocument().UnloadResources();

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Michael Dudek

unread,
May 6, 2014, 2:11:10 AM5/6/14
to pdfnet-w...@googlegroups.com
Hi Matt,
I'm sorry, I referred high level function, the core method that I'm using is DocumentViewer.CloseDocument. Thanks for recommendation to use UnloadResources, but Its necessary to unregister event handlers registered on body by DocumentViewer. Its used in Single Page Application and I need to dispose all DocumentViewer resources correctly. 

Is it possible to configure DocumentViewer to avoid registration of all event handlers? I'm using only methods for rendering of thumbnails & canvases, so I don't need other functionality related to UI interaction.

Thanks
Michael

Matt Parizeau

unread,
May 7, 2014, 2:27:04 PM5/7/14
to pdfnet-w...@googlegroups.com
Hi Michael,

For DocumentViewer it's assumed that it's alone on the page which is why it removes all the handlers and why WebViewer.js will create it inside an iframe. If you're just using thumbnail and canvas creation and don't want to use iframes then you could use Document directly. Document provides a LoadCanvasAsync function to create canvases (along with Pause/Resume/CancelLoadCanvas) and a LoadThumbnailAsync function for getting document thumbnails. You could take a look at the deck.js sample for an example of how this could be done.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Michael Dudek

unread,
May 9, 2014, 3:06:53 AM5/9/14
to pdfnet-w...@googlegroups.com
Hi Matt, 
the tip to use directly Document class is great, it would resolve all issues, but its missing support for search in document. Its the last requested feature that I need. Is it possible to search in document without using of DocumentViewer?  I've found that there are methods LoadPageText and GetTextPosition ...

Thanks a lot
Michael

Matt Parizeau

unread,
May 14, 2014, 2:05:06 PM5/14/14
to pdfnet-w...@googlegroups.com
Hi Michael,

Sorry I missed replying to this question earlier. You can refer to the text-position sample in the WebViewer download. It uses LoadPageText to search through the page and then GetTextPosition to place a highlight annotation at the text's location.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages