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

Unable to print document after scrolling through more than 10 pages. #8858

Closed
mullery opened this issue Aug 31, 2017 · 2 comments
Closed

Unable to print document after scrolling through more than 10 pages. #8858

mullery opened this issue Aug 31, 2017 · 2 comments

Comments

@mullery
Copy link

mullery commented Aug 31, 2017

Link to PDF file (or attach file here):

Configuration:

  • Web browser and its version: Chrome Version 60.0.3112.113 (Official Build) (64-bit)
  • Operating system and its version: Windows 10
  • PDF.js version: 1.9.506
  • Is an extension: No

Steps to reproduce the problem:

  1. Open the demo viewer at https://mozilla.github.io/pdf.js/web/viewer.html.
  2. Make sure you are viewing the first page in the document.
  3. Scroll to the bottom of the document (page 14), one page at a time.
  4. Click the print toolbar button to print the document.

What is the expected behavior? (add screenshot)

The document should print properly.

What went wrong? (add screenshot)

The document doesn't print and an exception is thrown:

image

Running through the javascript debugger, I can see the viewer is destroying PDFPageView objects as they fall outside the 10-page window of pages loaded into page view buffer. When a PDFPageView object is destroyed, the PDFPage object attached to it is cleaned-up and nullified. The printing exception is the result of attempting to access the viewport from one of these destroyed PDFPageView objects.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Aug 31, 2017

Removing the following line fixes this, so it's unfortunately a fairly serious (printing) regression from PR #8746. Note: It also affects the version of PDF.js that's shipping in Firefox.

this.pdfPage = null;

Rather that just removing that, which I assume may be bad considering what that PR intended to fix, I quickly looked if it'd be possible to make

pdf.js/web/pdf_viewer.js

Lines 931 to 935 in 51be278

/**
* Returns sizes of the pages.
* @returns {Array} Array of objects with width/height/rotation fields.
*/
getPagesOverview() {

asynchronous since then we could use

pdf.js/web/pdf_viewer.js

Lines 823 to 828 in 51be278

/**
* @param {PDFPageView} pageView
* @returns {Promise} Returns a promise containing a {PDFPageProxy} object.
* @private
*/
_ensurePdfPageLoaded(pageView) {
to re-fetch the deleted pdfPages before accessing them.

Currently however, the printService is initialized synchronously, so I'm not sure if we can easily transition it to be asynchronous instead.
@yurydelendik Since you wrote the patch in PR #8746, can you please help here?

@yurydelendik
Copy link
Contributor

I miss read function code and it's looks like destroy is a bad name for it. For now, we can safely, I think, remove this line.

Currently however, the printService is initialized synchronously, so I'm not sure if we can easily transition it to be asynchronous instead.

We cannot it is not possible due to beforeprint event nature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants