You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [ ] 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
Hi @VadimDez , I've integrated the ng2-pdf-viewer into my application (version : 9.0.0). I've tried to use the pageChange event within my PDF Viewer in this manner -
I am displaying one page at a time, and on click of next/previous page, the page variable is updated accordingly. However, I do not receive the pageChange callback. The callback is working fine (getting called) only when I set [show-all]="true", in case of a multi page viewer. In case of a single page viewer, it does not get triggered at all, even when we access a different page and the page variable is updated. Could it be possible that the event emitter is not working in case of a single page viewer ?
Following are the threads I have gone through before raising a request / issue here -
This worked fine. Please help me to confirm if my understanding is correct, so that we can work together to have this issue resolved.
The text was updated successfully, but these errors were encountered:
priyankamohile
changed the title
(pageChange) event not triggering - Single Page Viewer
(pageChange) event not getting emitted - Single Page Viewer
Aug 21, 2022
Bug Report or Feature Request (mark with an
x
)Hi @VadimDez , I've integrated the ng2-pdf-viewer into my application (version : 9.0.0). I've tried to use the pageChange event within my PDF Viewer in this manner -
HTML :
<pdf-viewer [src]="pageSrc" [autoresize]="true" [original-size]="false" [show-all]="false" [(page)]="page" [zoom]="zoompercent" [render-text]="false" [stick-to-page]="false" (after-load-complete)="onComplete($event)" (pageChange)="onPageChange($event)"></pdf-viewer>
Typescript :
onPageChange(page: number) { console.log("onPageChange : " + page); }
I am displaying one page at a time, and on click of next/previous page, the page variable is updated accordingly. However, I do not receive the pageChange callback. The callback is working fine (getting called) only when I set [show-all]="true", in case of a multi page viewer. In case of a single page viewer, it does not get triggered at all, even when we access a different page and the page variable is updated. Could it be possible that the event emitter is not working in case of a single page viewer ?
Following are the threads I have gone through before raising a request / issue here -
#73
#223
I debugged the code and noticed that on the 'pdf-viewer.component.ts', - https://github.com/VadimDez/ng2-pdf-viewer/blob/master/src/app/pdf-viewer/pdf-viewer.component.ts
under setupSinglePageViewer(), while setting up the event for 'pagechanging', the event is not being emitted.
fromEvent(eventBus, 'pagechanging') .pipe(takeUntil(this.destroy$)) .subscribe(({ pageNumber }) => { if (pageNumber !== this._page) { this.page = pageNumber; } });
Whereas in case of setupMultiPageViewer(),
fromEvent(eventBus, 'pagechanging') .pipe(takeUntil(this.destroy$)) .subscribe(({ pageNumber }) => { if (this.pageScrollTimeout) { clearTimeout(this.pageScrollTimeout); } this.pageScrollTimeout = window.setTimeout(() => { this._latestScrolledPage = pageNumber; this.pageChange.emit(pageNumber); }, 100); });
The fix that I tried and tested at my end was -
setupSinglePageViewer() { assign(PDFJS, 'disableTextLayer', !this._renderText); const eventBus = createEventBus(PDFJSViewer, this.destroy$); fromEvent(eventBus, 'pagechanging') .pipe(takeUntil(this.destroy$)) .subscribe(({ pageNumber }) => { if (pageNumber !== this._page) { this.page = pageNumber; } this.pageChange.emit(pageNumber); });
This worked fine. Please help me to confirm if my understanding is correct, so that we can work together to have this issue resolved.
The text was updated successfully, but these errors were encountered: