Print to PDF of HTML document produces bad quality PDF document
Categories
(Core :: Printing: Output, defect, P3)
Tracking
()
People
(Reporter: petr.kisselev, Unassigned)
References
Details
Attachments
(5 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Steps to reproduce:
-
Open any webpage (I provide an HTML document as attachment for reference)
-
Ctrl+P or click on hamburger menu then click on "Print...", the printing dialog appears
-
In the drop-down list under "Destination", select "Save to PDF" or any other print-to-document printer, all other options do not influence the result as far as I aware
-
Save the generated PDF file to your chosen destination and open it
Actual results:
At this point you will notice several issues with the resulting document:
- text that was selectable in the original HTML is unselectable in the generated PDF
- links and image links are non-clickable (this is a supported feature of PDF documents)
- some images are missing
It almost looks like Firefox does a (bad) printscreen of the webpage before exporting the image as a PDF, instead of trying to generate a well-formed PDF document.
Expected results:
In the resulting PDF:
- text should be selectable and searchable
- links and image links should work as well
- dynamic elements (like interactive images) should be rendered into static images
Reporter | ||
Comment 1•3 years ago
|
||
Exemples of rendered PDFs by different applications for comparison.
Reporter | ||
Comment 2•3 years ago
|
||
Reporter | ||
Comment 3•3 years ago
|
||
Comment 4•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Toolkit::Printing' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Comment 5•3 years ago
|
||
Text is selectable here on Linux fwiw... Maybe this is Windows-specific?
Reporter | ||
Comment 6•3 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)
Created attachment 9282395 [details]
mini-rapport-deconv-from-firefox-linux.pdfText is selectable here on Linux fwiw... Maybe this is Windows-specific?
Text is selectable indeed. Although images are still pretty distorted.
Does anyone know if Firefox is using its own HTML to PDF converter, or if it simply calls one available on the host system ?
Comment 7•3 years ago
|
||
We use our own rendering. "Save as PDF" uses cairo on the final step, "Microsoft print-to-pdf" etc use Windows printing APIs.
Reporter | ||
Comment 8•3 years ago
|
||
So the possibility exists that Firefox's "Save as PDF" creates a PDF with selectable text, but then "Microsoft print-to-pdf" ruins that ?
Still, the way images are distorted during the conversion phase is still an issue.
Comment 9•3 years ago
|
||
I think the issue is that Chrome is not squishing the canvas but we are.
Chrome's preview takes forever here, but it draws correctly-sized canvases which overflow the viewport. We instead draw wrongly-sized canvases. None of those are ideal. Part of the issue is that the page is built using absolute pixel values, but doesn't react to print so we end up with a bunch of elements sized to the size of the original page's viewport. Print output in Firefox is much more reasonable if you shrink your window to an aspect-ratio that matches the print paper size.
So this is a mix of a page issue (there's not much we can do if the page says "this canvas is 2000px wide" and then listens to resize events) and an interop issue with Chrome (haven't dug into which browser is right according to the spec).
Reporter | ||
Comment 10•3 years ago
|
||
(In reply to petr.kisselev from comment #8)
So the possibility exists that Firefox's "Save as PDF" creates a PDF with selectable text, but then "Microsoft print-to-pdf" ruins that ?
Scratch that, Firefox's "Save as PDF" and "Microsoft print-to-pdf" appear as different printers in Firefox's printing interface. So this might be a Windows specific issue with cairo or whatever Firefox's "Save as PDF" relies on.
(In reply to Emilio Cobos Álvarez (:emilio) from comment #9)
I think the issue is that Chrome is not squishing the canvas but we are.
Chrome's preview takes forever here, but it draws correctly-sized canvases which overflow the viewport. We instead draw wrongly-sized canvases. None of those are ideal. Part of the issue is that the page is built using absolute pixel values, but doesn't react to print so we end up with a bunch of elements sized to the size of the original page's viewport. Print output in Firefox is much more reasonable if you shrink your window to an aspect-ratio that matches the print paper size.
So this is a mix of a page issue (there's not much we can do if the page says "this canvas is 2000px wide" and then listens to resize events) and an interop issue with Chrome (haven't dug into which browser is right according to the spec).
I'm not sure if I agree with this assessment. Even when you shrink the window width to something resembling a paper's aspect ratio, Firefox tries to squeeze the image vertically and while the top part of an image is rendered with correct proportion, the bottom part of the image gets vertically squeezed out of existence. Also, the blank space left at the top of the next page hints at Firefox leaving it for the bottom part of the image that didn't fit on the previous page.
Comment 11•3 years ago
|
||
The severity field is not set for this bug.
:emilio, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 13•3 years ago
|
||
It seems to.
Description
•