Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox -> broken browser history back button when load PDF as byte array #44

Closed
dafinel opened this issue Aug 30, 2019 · 4 comments · Fixed by #250
Closed

Firefox -> broken browser history back button when load PDF as byte array #44

dafinel opened this issue Aug 30, 2019 · 4 comments · Fixed by #250

Comments

@dafinel
Copy link

dafinel commented Aug 30, 2019

When you load the pdf using a byte array or a blob you have to press back twice come back to previos page.

For example : You have an overview with a list of files, and when you click on on row will be redirected to a detail page where the pdf content is shown. In this case I have to press twice back button to the to the overview page.

This issue can be reproduced on the demo app : https://ng2-pdfjs-viewer.azurewebsites.net/bytearray

Steps:
Browser: Firefox

  1. Click on "Simple Configuration" from sidebar
  2. Click on " Blob and Byte array " from sidebar
  3. Press back button

Actual result: The frame with the pdf content is cleared, and I have to press again back to go to "Simple Configuration"
Expected result: Navigate back to "Simple Configuration"

If you know a solution for this issue please help me. I may case the back button is integrated in the application and we have an issue opened by the client

@codehippie1
Copy link
Contributor

@dafinel Can you try this directly at
https://mozilla.github.io/pdf.js/web/viewer.html#page=2
and let me know.

Looks like an issue of underlying component.

@Ciferlingvulo
Copy link

I have a somewhat similar issue. I think it's worth mentioning here instead of creating a new issue.

I have a few buttons on a page that load a different document in the same PDF viewer. The PDF are loaded as byte array too, as in the original issue. The code looks like this :

  @ViewChild('pdfViewer', { static: false }) public pdfViewer: PdfJsViewerComponent;
  @ViewChild('pdfViewerContainer', { static: false }) public pdfViewerContainer: ElementRef<HTMLElement>;

  displayPDF(pdfIndex: number): void {
    this.pdfIndex = pdfIndex;
    this.getPDF(pdfIndex).subscribe((file: any) => {
      this.pdfViewer.pdfSrc = file;
      this.pdfViewer.zoom = 'page-fit';
      this.pdfViewer.refresh();
      setTimeout(() => {
        this.pdfViewerContainer.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
      }, 0);
    });
  }

Everything is loaded fine and work as intended, but when I click on the back button of my browser, it stays on the same page and simply goes back to the previous file that was loaded in the PDF viewer.
This is true on every browser I've tried, plus I get the issue mentioned by OP that PDF content is cleared when on Firefox.

Regards.

@roma2341
Copy link

roma2341 commented Jul 12, 2022

Same issue in Chrome, when i click browser Back button it stays on the same browser page.

@MaxEtMoritz
Copy link
Contributor

Same Issue here. Seems to be caused by the iFrame the PDF viewer is in and strange Behavior of Firefox to include iFrame URL changes in the back/forward History.
A possible workaround is mentioned here: officert/vue-friendly-iframe#20 (comment)

MaxEtMoritz added a commit to MaxEtMoritz/ng2-pdfjs-viewer that referenced this issue Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants