Error loading document: TypeError: Cannot read property 'off' of undefined

41 views
Skip to first unread message

David Compton

unread,
May 19, 2017, 1:03:00 PM5/19/17
to PDFTron WebViewer
I am getting the following error in the Chrome console each time I load a document into the WebViewer.

CoreControls.js:1072 Uncaught (in promise) Error: Error loading document: TypeError: Cannot read property 'off' of undefined
    at Object.onError.c.onError (CoreControls.js:1072)
    at CoreControls.js:1077
    at <anonymous>
onError.c.onError @ CoreControls.js:1072
(anonymous) @ CoreControls.js:1077

Do you have any suggestions as to why this is occurring and how the error can be fixed.

Kind regards,

David

Justin Jung

unread,
May 19, 2017, 7:02:08 PM5/19/17
to PDFTron WebViewer on behalf of David Compton
We are having trouble reproducing the error. The steps we tried includes:
1. Loading a file in WebViewer instance
2. Loading another file using readerControl.loadDocument('FILE_PATH')

Could you elaborate on steps to reproduce the issue? Which version of WebViewer are you using? Can you send us the file that causes the issue?

Justin Jung
Software Developer
PDFTron Systems Inc.

David Compton

unread,
May 23, 2017, 11:33:54 AM5/23/17
to PDFTron WebViewer on behalf of Justin Jung
Hi Justin,

I have attached one of the files that gives these errors in the console.  My app is developed with Ionic 2.  The errors occur when running the app locally in Chrome browser. 

Actually I've just now discovered that the error only seems to happen when in html5 mode.  When the web viewer is in html5mobile mode the error does not occur.

I tracked down the error to the following code:

// Disable double tap when in free hand annotation mode
self.readerControl.$wrapper.off('dblclick');
self.readerControl.$wrapper.off('dbltap');
self.readerControl.$wrapper.off('doubletap');
self.readerControl.$wrapper.on('dblclick dbltap doubletap', function () {
if (self.readerControl.getToolMode() !== PDFTron.WebViewer.ToolMode.AnnotationCreateFreeHand) {
self.readerControl.onDoubleTap.call(self.readerControl, arguments[0]);
}
});

For now I have gotten rid of the errors by testing if readerControl.$wrapper is undefined - if so then I do not run this code.  

Regards,

David

--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfnet-webviewer+unsubscribe@googlegroups.com.
To post to this group, send email to pdfnet-webviewer@googlegroups.com.
Visit this group at https://groups.google.com/group/pdfnet-webviewer.
For more options, visit https://groups.google.com/d/optout.

capitalprojectsfrontpage_196e0cd2-af87-441a-8543-8a537ffe65ff.xod

Justin Jung

unread,
May 23, 2017, 6:58:44 PM5/23/17
to PDFTron WebViewer on behalf of David Compton
readerControl.$wrapper isn't defined in desktop viewer, so it would be correct to check to see if it is defined before running the code.
Reply all
Reply to author
Forward
0 new messages