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

Issue printing PDF using Firefox #695

Open
bababash opened this issue Oct 18, 2023 · 12 comments
Open

Issue printing PDF using Firefox #695

bababash opened this issue Oct 18, 2023 · 12 comments

Comments

@bababash
Copy link

bababash commented Oct 18, 2023

Hello Print.js team,
I'd like to report an I am experiencing using Firefox. This is working perfectly in Chrome

Implementation:

<button type="button" onclick="printJS('/static/test.pdf')">Print</button>
test.pdf was copied from this repository
Using Print.js v1.6.0
Using Firefox v118.0.2 (64-bit)

Issue:

Upon clicking the button, I get the following output in my console

Warning: Invalid absolute docBaseUrl: "blob:http://127.0.0.1:8000/ff77f293-d166-45ff-a02a-d3e4c7852f7a".

(pdf.worker.js:970:13)

Warning: Bad value, for custom key "AAPL:Keywords", in Info: .

(pdf.worker.js:970:13)

PDF 8eed11de459c2ed35fec410bf057a870 [1.3 Mac OS X 10.11.4 Quartz PDFContext / Word] (PDF.js: 3.10.86 [c72cb5436])

(viewer.js:1518:13)

Uncaught NS_ERROR_FAILURE:

([print.min.js:1:4198])

Hope you can help me!

@bababash
Copy link
Author

I also tried using https://www.npmjs.com/package/print-js-updated which resulted in the same error.

Using the version from the CDN https://printjs-4de6.kxcdn.com/print.min.js opens the PDF viewer on Firefox without throwing an error (doesn't print though)

@SaschaAusUlm
Copy link

SaschaAusUlm commented Oct 19, 2023

Seeing the same:

Warning: Invalid absolute docBaseUrl: "blob:https://xxxxxxxxxxxxxxxxxxxxxxx/126c4566-4c9b-4923-a0a4-ec4aff6591c0". pdf.worker.js:970:13
PDF 816648aa36057888347bf1df09e19bd1 [1.4 Skia/PDF m79 / Chromium] (PDF.js: 3.10.86 [c72cb5436])

I see the PDF in my UI, but when I print it's just a blank page and the preview is also white.

It works fine in Edge and Chrome.

Firefox: Version 118.0.2 (64-Bit)

@SaschaAusUlm
Copy link

I am seeing that there was a fix committed 8 months ago:

Merge pull request #657 from amoilanen/fix-firefox-110-pdf-printing

but no release was done?

@SaschaAusUlm
Copy link

I tried print-js-updated which includes the made but unreleased fix and with that, it works again for me. Sad that this project is going to waste.

@bababash
Copy link
Author

Thanks @SaschaAusUlm I'll try again. How did you implement it?

@SaschaAusUlm
Copy link

SaschaAusUlm commented Oct 20, 2023

Hey @bababash,

for us, printing is just a one-liner:

public printReport(): void { printJS({ printable: this.selectedReport.downloadUri, type: 'pdf', showModal: true }); }

with printable being a link to one of our PDFs in one of our Blob storages. To make it work again in Firefox, I just had to pull in the patched library with npm and adjust the import.

@wmadam
Copy link

wmadam commented Oct 31, 2023

Hello, I patched the library with the code from the PR, but I still get a blank page in firefox v119.0 when printing (no errors in console though).
Can anyone reproduce this issue or is there an alternative fix?

@lucasjuna
Copy link

lucasjuna commented Dec 2, 2023

I've installed print-js-updated
Then used import printJS from "print-js-updated";
And it's working in latest version of Firefox.
But don`t remove print-js.

@bababash
Copy link
Author

Hey @bababash,

for us, printing is just a one-liner:

public printReport(): void { printJS({ printable: this.selectedReport.downloadUri, type: 'pdf', showModal: true }); }

with printable being a link to one of our PDFs in one of our Blob storages. To make it work again in Firefox, I just had to pull in the patched library with npm and adjust the import.

I tried again with print-js-updated from npm. It appears to have the changes merged in but hard to tell. How come there is a disconnect between npm and github?

The issue still exists with Firefox. Works perfectly in Chrome.
From Firefox console:

Source map error: Error: request failed with status 404
Resource URL: "path to printjs"
Source Map URL: print.map

Warning: Invalid absolute docBaseUrl: "blob:http://127.0.0.1:8000/6f9819a6-0357-4486-b648-38dcf047f33c". pdf.worker.mjs:339:13
PDF 8e4fcce84c89827e7d1aa79671646b36 [1.3 pypdf / -] (PDF.js: 4.0.67 [5c45dfa0a]) viewer.mjs:10800:13
Uncaught NS_ERROR_FAILURE: print_updated.js:1:4694

@bababash
Copy link
Author

If anyone else is hunting for a solution, this is what worked for me to print a pdf in chrome/firefox:
https://gist.github.com/timdown/cfacd32f6b5e439bb02aaf142343ce4c

@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Feb 15, 2024

I'm also having this same issue. It seems to work intermittently in Firefox which is baffling.

Nevermind, I was able to get it working with print-js-updated.
Thanks!

@eddielu
Copy link

eddielu commented Oct 25, 2024

Looks to be broken now again. Even the example homepage is broken: https://printjs.crabbly.com/. Just shows a blank page.

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

No branches or pull requests

6 participants