Closed Bug 1697778 Opened 4 years ago Closed 3 years ago

The pages of some PDF files are shrunk in the top left corner of the viewer in print preview and on the printed pages as well

Categories

(Firefox :: PDF Viewer, defect)

All
Windows 10
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox86 --- affected
firefox87 --- affected
firefox88 --- affected

People

(Reporter: goztelyk, Assigned: emilio)

References

Details

(Whiteboard: [pdfjs-printing])

Attachments

(3 files, 1 obsolete file)

I am experiencing this decade-old bug on Firefox 86.0 (64-bit) stable release, Windows 10 Pro.

PDFs are displayed with proper scale in Firefox built-in PDF viewer. However some files appear shrunk in the top left corner of the viewer of the redesigned print preview screen and they are printed accordingly.

"Fit to page width" and "Scale: 100% options" don't fix this behavior. Setting manually the print scale at 127% circa results in the affected PDF being displayed and printed with correct proportions. See the attachments.

Also worth mentioning that in about:config all the "print_scaling" values are set correctly at 1.

Steps to reproduce:

  1. Download and open with Firefox one of the problematic PDF files (ex. https://www.academia.edu/44947095/Desde_la_periferia_Mujeres_de_la_Ilustraci%C3%B3n_en_province_ or other random PDF files)
  2. Click on the printer icon to open the print preview screen
  3. The actual PDF page is shrunk in the top left corner of the viewer area
  4. Choosing "Fit to page width" or "Scale: 100%" doesn't change anything
  5. Clicking "Print" results in the PDF page being shrunk in the top left corner of the printed page

Expected Results:
The PDF file should be previewed and printed with correct proportions, as it happens using the very same file with every other browser of PDF viewer.

Actual results:
The PDF page is shrunk in the top left corner of the viewer in the print preview screen and on the printed page as well.

(Please note: in the uploaded attachments I have selected "Microsoft print to PDF" as a printer just for privacy reasons, but the preview doesn't change regardless of the selected printer)

Reproduced on the latest versions of Firefox Nightly 88.0a1 (2021-03-12), beta 87.0b9 and release 86.0.1.

Setting up flags and a component in order to get the dev team involved.
If you feel it's an incorrect one please feel free to change it to a more appropriate one.

Assigning it a severity of S3.

Not a recent regression as this issue can be reproduced back to Firefox 70.0.

Severity: normal → S3
Status: UNCONFIRMED → NEW
Component: General → Print Preview
Ever confirmed: true
Product: Firefox → Core

Thanks for reaching out.

I just believe that the severity has to be raised to S2: printing PDFs from the browser is an extremely common workflow both in office and home use.

A big percentage of PDF files - seemingly a half of the ones I have been testing - is affected by this bug, and none of the two 'workarounds' are effective, for one is setting a scale of 127% and facing a slight loss of quality due to scale mismanagement, and the other one is using another browser altogether.

Can you confirm that setting layout.display-list.improve-fragmentation=false in about:config fixes this for you? I think this is bug 1698136, which bisected to turning that on by default, but want to double-check before duping. Thanks!

(And yeah, I agree this is quite severe, and should be reasonably straight-forward to fix, I'd think)

Flags: needinfo?(goztelyk)

Thank you as well!

I have set the value to False as you suggest, but unfortunately the issue is still there. I have also tried to restart Firefox and open several affected PDF files, but nothing has changed.

Flags: needinfo?(goztelyk)

Ok, so using the paper in comment 0 (a bit unfortunate that you have to create an account to access to research, but it's better than a paywall I guess!) I can reproduce it, and it doesn't seem to be a regression like bug 1698136 (I can reproduce it in 78).

I can get the right rendering if I tweak the scale print setting to be 125 for example. So it seems like PDF.js is not scaling to the full page size (even though it does when rendering to the screen...).

Component: Print Preview → PDF Viewer
Product: Core → Firefox

Ok, I took a poke and I think I see what's going wrong.

Assignee: nobody → emilio

An important update related to this bug: I have found a 'dark-themed' PDF which I would have called 'not affected' by this bug. However, when viewed in the print preview, it shows white borders on the right side and below, as if an almost-negligible downscaling has occurred.

Dark themed PDF:
https://anonymousplanet.org/guide-dark.pdf

Unthemed version (just for reference):
https://anonymousplanet.org/guide.pdf

Attached file GitHub Pull Request (obsolete) (deleted) —

(In reply to goztelyk@protonmail.com from comment #9)

An important update related to this bug: I have found a 'dark-themed' PDF which I would have called 'not affected' by this bug. However, when viewed in the print preview, it shows white borders on the right side and below, as if an almost-negligible downscaling has occurred.

Dark themed PDF:
https://anonymousplanet.org/guide-dark.pdf

Unthemed version (just for reference):
https://anonymousplanet.org/guide.pdf

That seems like an slightly different issue. That PDF is using a custom page size (595.32pt 841.92pt) which is almost A4 but not quite (not sure why).

When Firefox supports custom page sizes in the @page rule (bug 1647845 is working on that) I think that should be fixed, in the preview at least... But worth filing a separate bug on it.

Ok, so I think this is invalid. It was pointed out in the pdf.js review above that my fix was incorrect, and digging more I found out that that PDF for example has a page size of 6.5x9.0 inch.

PDF.js is not passing down the page size to Firefox (it will do once we support @page { size }, which as I said is in progress. So if your printer default paper size is e.g. A4, then we'd show the margins of the paper, which is expected.

So now the question is whether we should just do this or we should try to scale up the page when you request to print in A4 size for example. And otherwise this will be automatically fixed when we support @page { size }.

So if you print that PDF with e.g. Chrome / Edge, they scale the page up? (I don't have a printer handy right now)

Or do they just select a different page size automatically?

Flags: needinfo?(goztelyk)

Ok, at least Evince does add margins as needed to center the page, rather that sticking it into the left corner. That seems reasonable enough!

Attached file Alternative PR (deleted) —

See this comment for screenshots of before and after. I think with that we should be able to close this bug.

Once we support @page { size } we could start printing to the real size of that PDF (if your printer supports it of course). Otherwise the rendering in the "After" screenshot is what I'd expect if you print to A4.

Attachment #9208955 - Attachment is obsolete: true

OK, I have just ran complete tests using Adobe Acrobat DC, Google Chrome and Microsoft Edge.

I confirm that my printer is in A4 mode and that I am using A4-sized sheets (as intended, for I leave in Europe).

Adobe Acrobat DC: the PDF file from comment 0 is rendered correctly by the main viewer, just like on Firefox/PDF.js. Print preview's "Fit" option will preview and print the file as is. "Shrink oversized pages" and "Custom scale: 100%" will preview and print the document centered, scaled down, and with large white margins around it.

Google Chrome: the PDF file from comment 0 is rendered correctly by the main viewer, just like on Firefox/PDF.js. Print preview's "Default" and "Custom: 100%" scale options will preview and print the file with the same 'shrinking in the top left corner' that we are trying to fix. "Fit to printable area" option will render the file almost correctly: centered and with a very thin margin around the actual page. "Fit to paper" will preview and print the document as is.

Microsoft Edge: the PDF file from comment 0 is rendered correctly by the main viewer, just like on Firefox/PDF.js. Print preview's "Fit to printable area" will preview and print the document as is. The alternative custom scale value is set by default at 122%, which previews and print the document as is (just like the "Fit to printable area" option). Setting the custom scale to 100% will preview and print the document centered, scaled down and with large white margins around it (just like Adobe Acrobat DC's "Custom scale: 100%" option).

If I look at your comment on Github, the "After" screenshot looks like Adobe Acrobat DC's "Custom scale: 100% option". So yes, we are still lacking a print mode that prints the document as is, without additional margins. But you have made a lot of progress. Well done!

Flags: needinfo?(goztelyk)

Ok, so in order to implement such a thing Gecko would need to have the original pdf page size. We could implement custom APIs and expose them to pdf.js, but we need to implement such a thing for all websites whenever we support @page { size }, so given that work is pretty close to land it's probably worth waiting for that.

Fine, thank you very much!

Whiteboard: [pdfjs-c-printing]
Whiteboard: [pdfjs-c-printing] → [pdfjs-printing]

This bug was fixed by:
Bug 1702796 - Update pdf.js to version 2.8.320 r=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D110697

Regarding comment 9, I cannot reproduce it with latest nightly, so I assume it is fixed, too.

Status: NEW → RESOLVED
Closed: 3 years ago
Depends on: 1702796
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: