question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events are not triggered when open pdf in external window

See original GitHub issue

Hey! There is a problem with events, when open pdf in external window. They are not triggered even with ‘viewerId’ attribute. Here is my code:

##HTML

 <a *ngIf="document.s3_link" class="document-title" (click)="openDocument(document)">{{ document.description }}</a
                    >
<ng2-pdfjs-viewer
        #externalPdfViewer
        viewerId="MyUniqueID"
        [externalWindow]="true"
        (onDocumentLoad)="highlightSearchTerm()"
    ></ng2-pdfjs-viewer>

##TypeScript

openDocument(document): void {
        this.getDocumentBlob(document.s3_link).subscribe(res => {
            this.externalPdfViewer.pdfSrc = res
            this.externalPdfViewer.downloadFileName = document.description
            this.externalPdfViewer.refresh()
        })
    }

getDocumentBlob(link): Observable<any> {
        let headers = new HttpHeaders()
        headers = headers.set("Accept", "application/pdf")
        return this.http.get(link, { headers: headers, responseType: "blob" })
    }

    highlightSearchTerm() {
        this.externalPdfViewer.PDFViewerApplication.findController.executeCommand(
            "find",
            {
                caseSensitive: false,
                findPrevious: undefined,
                highlightAll: true,
                phraseSearch: true,
                query: this.initQuery,
            }
        )
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
neuweilercommented, Feb 25, 2020

For pdf within same window, make sure to provide a viewerID to receive accurate events.

Please, include this in the documentation/readme.me ! It cost me hours to find this mentioned in a bug report. (actually I almost gave up on the plugin which works great otherwise).

0reactions
codehippie1commented, Mar 4, 2020

@neuweiler Thanks for the kind words. I have updated the documentation to reflect this. Everywhere events are mentioned - viewerID is mentioned as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Events are not triggered when open pdf in external window
I have a problem with events, when open pdf in external window. They are not triggered even with 'viewerId' attribute. Here is my...
Read more >
Troubleshoot viewing PDF files on the web - Adobe Support
In Reader or Acrobat, right-click the document window, and choose Page Display Preferences. From the list at left, select Internet.
Read more >
MS Edge is permanently hijacking PDF files when I am trying ...
Open Microsoft Edge · Click on the three dots (…) from the right top corner. · Select Settings from the drop down and...
Read more >
webContents | Electron
Not emitted if the creation of the window is canceled from webContents. ... This event will be emitted after did-start-navigation and always before...
Read more >
How to track PDF downloads in Google Analytics
If you are linking to a PDF that opens in a new window (by using ... bar below reads “Tags Fired on this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found