Reputation: 29213
Is anyone else finding that the ng2-pdfjs-viewer
Angular library doesn't ever trigger the onDocumentLoad
function ?
<ng2-pdfjs-viewer
#externalPdfViewer
[viewerId]="pdfName"
(onDocumentLoad)="onDocumentLoaded($event)"
zoom="page-width"
[fullScreen]=true
[pdfSrc]="attachment.pdfName"
[downloadFileName]="pdfName">
</ng2-pdfjs-viewer>
Lots of people have noticed that if the pdf is open in a different window, then they get this behavior, but for me, my pdf is in the same window.
The "ng2-pdfjs-viewer.component.ts" file contains a receiveMessage
function which is where an onDocumentLoad
function would get called, but I added some logging around this function, and this entire function never gets called.
public receiveMessage(viewerEvent) {
...
else if (this.onDocumentLoad && event == "pagesLoaded") {
this.onDocumentLoad.emit(param);
}
My pdf is displayed perfectly by the library, but I need to know when the pdf has finished rendering, so I can search for, and highlight certain words in it.
Upvotes: 2
Views: 776
Reputation: 549
Below seems to work for me
<ng2-pdfjs-viewer
#pdfViewer
[openFile]="false"
[download]="true"
[print]="true"
[viewBookmark]="false"
viewerId="document"
(onDocumentLoad)="loadComplete()"
pagemode="none"
>
</ng2-pdfjs-viewer>
The major difference what is see is in your code you pass it as [viewerId]
while i pass it without the square brackets
Upvotes: 1