ng2-pdf-viewer: Cannot read property 'div' of undefined
- [x] bug report -> please search issues before submitting
- [ ] feature request
When page changed it’s success to change the page number, but It’s failed when scrolling to the page because of this error :
ERROR TypeError: Cannot read property 'div' of undefined
at PDFViewer._resetCurrentPageView (pdf_viewer.js:1556)
at PDFViewer._setCurrentPageNumber (pdf_viewer.js:1281)
at PDFViewer.set (pdf_viewer.js:1858)
at eval (pdf-viewer.component.js:258)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4620)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at ZoneTask.invokeTask (zone.js:499)
at ZoneTask.invoke (zone.js:488)
I’m using Angular 5.0.3 and ng2-pdf-viewer 3.0.2
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 15
- Comments: 16 (1 by maintainers)
I had the same problem. I fixed it by removing
[stick-to-page]="true"from my html definition. You should try to check your configuration.I had the same error and I fixed it with following changes.
var elt = views[index].div;It is inside ‘backtrackBeforeAllVisibleElements’ function.var elt = views[index-1].div;and save.I’m using single-pdf-viewer and I had a similar problem:
In a node_modules, in a file ‘pdf_viewer.js’ (node_modules/pdfjs-dist/web/pdf_viewer.js) from line 3326 starts method:
Problem was that ‘pageView.div’ was ‘undefined’, and solution was simple:
so method looks like:
pdf viewer container should be not be in collapsible panel. container Div should be open. no any animation to open div.
I am also getting the error cannot read property of undefined when I pop a page which renders the PDF in ionic.
I am using Ionic 3.20.0 and ng2-pdf-viewer ^5.1.1
I got the same error when I incorporate
pdf-viewerinto aMatDialogand close the dialog.