Skip to content

When printing a PDF on a Android chrome, only the first page will be printed #2890

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

Open
LgnMs opened this issue May 7, 2025 · 6 comments
Open
Assignees
Labels

Comments

@LgnMs
Copy link

LgnMs commented May 7, 2025

I find this code, I think Android needs a delay of 1500ms yet.

// pdf_print_service.js

performPrint() {
    this.throwIfInactive();
    return new Promise(resolve => {
      // Push window.print in the macrotask queue to avoid being affected by
      // the deprecation of running print() code in a microtask, see
      // https://github.com/mozilla/pdf.js/issues/7547.
      setTimeout(() => {
        if (!this.active) {
          resolve();
          return;
        }
        print.call(window);
        // Delay promise resolution in case print() was not synchronous.
        // modified by ngx-extended-pdf-viewer #83
        const isIOS = navigator.platform && [
          "iPad Simulator",
          "iPhone Simulator",
          "iPod Simulator",
          "iPad",
          "iPhone",
          "iPod"
        ].includes(navigator.platform)
        // iPad on iOS 13 detection
        || (navigator.userAgent.includes("Mac") && "ontouchend" in document);

        setTimeout(resolve, isIOS ? 1500 : 20); // Tidy-up.
        // end of modification by ngx-extended-pdf-viewer
      }, 0);
    });
  }
@stephanrauh stephanrauh self-assigned this May 12, 2025
@stephanrauh
Copy link
Owner

@KillerCodeMonkey I'm not sure if you're using Android, but it's worth a try... are you aware of any print problems with Android? Should I increate the delay, like I already do for iOS?

@manubauer
Copy link

I am facing the same issue on macos with chrome - only the first page shows up.
Package version 18.1.14

@KillerCodeMonkey
Copy link
Contributor

KillerCodeMonkey commented May 13, 2025

@stephanrauh tested in chrome and firefox for android and i can confirm that only the first page is rendered in chrome, but it is working in firefox :).

EDIT: Tested chromium based Brave and there it only prints the first page as well.

@stephanrauh
Copy link
Owner

@manubauer Can you test if the showcase prints correctly on your machine? I bet it's a CSS issue in your case. I've tested it a few seconds ago, and I see all 333 pages of my test document.

@KillerCodeMonkey
Copy link
Contributor

KillerCodeMonkey commented May 14, 2025

@stephanrauh it seems that the pdf viewer is trying to print the wrong dom node, when using inside a dialog or something similar.

on your demo page (simple demo). it does not print the pdf, when using the print button on Android Brave Browser.

Same happens in my app, where a pdf is shown in a dialog/modal. It prints the page body below.

In the demo it prepares very long all >300 pages, but this is the preview
Image

But it is working in Firefox based browsers.

@stephanrauh
Copy link
Owner

@KillerCodeMonkey I didn't expect that behavior. It feels like a hot trace!

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

No branches or pull requests

4 participants