x)- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [X ] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request
StackBlitz Reproduction
https://stackblitz.com/edit/ng2-pdf-viewer-bwntrw?devtoolsheight=33&file=src/app/app.component.ts
Two way page binding for always showing pdf last page is throwing console.error while executing correctly. 驴Why is the error showing and is there any way I could prevent this from happening? It seems scrollIntoView method somehow losses pdf pages array.
That's not a bug. (after-load-complete) is called immediately after loading the document. At this point in time, the document hasn't been rendered yet. So there are exactly zero pages. That's why setting page="3" raises an error.
You can add a timeout, or you can also implement (text-layer-rendered)="jumpToLastPage($event)" like so:
export class AppComponent {
src = "https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf";
pdfPage: number;
lastPage: number;
...
finishPdfLoad(event: PDFDocumentProxy) {
this.lastPage = event.numPages;
}
jumpToLastPage(event: any) {
this.pdfPage = this.lastPage;
}
}
Thank you so much for the clarification. Worked like a charm.
Most helpful comment
That's not a bug.
(after-load-complete)is called immediately after loading the document. At this point in time, the document hasn't been rendered yet. So there are exactly zero pages. That's why settingpage="3"raises an error.You can add a timeout, or you can also implement
(text-layer-rendered)="jumpToLastPage($event)"like so: