Pdf.js: Auto-rotate for printing does not work

Created on 19 Dec 2017  ·  22Comments  ·  Source: mozilla/pdf.js

Attach (recommended) or Link to PDF file here: http://www.co.dutchess.ny.us/CountyGov/Departments/StopDWI/DontBlowIt.pdf

Configuration:

  • Web browser and its version: Firefox 57.0.2 (64 bits)
  • Operating system and its version: Arch Linux
  • PDF.js version: 1.9.583
  • Is a browser extension: no (embedded in Firefox)

Steps to reproduce the problem:

  1. Enable pdfjs.enablePrintAutoRotate in about:config.
  2. Open the file.
  3. Open the print preview.
  4. Notice that the landscape pages are not rotated.

What is the expected behavior? (add screenshot)
They should be rotated to fill the entire landscape page.

What went wrong? (add screenshot)
They are sized onto a portrait page.

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
-

4-printing

All 22 comments

This may be the same or related issue.

  1. Go to Free Monthly Calendar or Planner Printable Online
  2. Click "Generate calendar" using all the default settings.

Currently, the calendar displays in the browser in "Landscape" orientation, but when the page is printed to a printer, it comes out in Portrait mode.
Instead, Firefox should respect the orientation designated by the PDF and print the page in landscape mode.

This seems to have broken recently because I never got any complaints about it before.
NOTE: The PDF is generated using FPDF to be in landscape orientation--that code hasn't changed. Also, if I save the PDF to disk and open in Adobe Acrobat Reader, then it correctly prints in Landscape orientation.

Here's my configuration:
Firefox 57.0.2 (64-bit) Win10
Page Setup is configured to print in Portrait mode
pdfjs.enablePrintAutoRotate set to default, which is false.

Just curious if this is ever going to be fixed. This has always been an issue, but when we could use adobe inside firefox there was a work around. Every other browser out there can handle this except for Firefox, which makes using in a corporation difficult.

Is this issue is fixed or Not ?

@timvandermeij Is this issue fixed? If not can I work on this?

I don't think it's fixed, so if you can reproduce it you can work on this.

@timvandermeij这个问题是否已解决?如果没有,我可以解决这个问题吗?

@sd1998 请问你怎么解决这个问题呢。

I've been researching into this, and reading over the different threads related to this issue.
I feel like a consistent method to getting this issue to appear needs to be established.
Half of the responses have been about:config
pdfjs.enablePrintAutoRotate set to default, which is false.
and some people have this enabled to true.

Then on top of that I haven't seen anyone using MacOS complain and in Windows there are several operating systems that are affected.
Can people who are having this issue please confirm that resetting the printer settings under about:config Firefox themselves has been tried?
https://support.mozilla.org/en-US/kb/fix-printing-problems-firefox
and make sure they are restarting their Firefox browser after resetting the printer?

I have done all the fix issues on the link above and still have the same problem, testing between each step. Here is a pdf I did a search for and used for my testing: http://www.calendarpedia.co.uk/download/weekly/weekly-calendar-2019-landscape-time-management-1-hour.pdf

To clarify, Chrome, Internet Explorer, Edge and the new Edge browsers all autorotate the page so it comes out in landscape as intended, Firefox does not. And the print icon you click to print in the pdf render doesn't have an option on the initial page to change the orientation you have to dig down to locate it. Most of my users just hit the button and print so there is a lot of wasted paper, the worse of the users I have moved to another browser to stop the whining.

Continuing to review into this, and had a question.
So under firefox_print_services I see canvas.mozPrintCallback = function(obj) {
When I researched more into mozPrintCallback I found that this was an experimental api
Which lead me to the following page:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement
HTMLCanvasElement.mozPrintCallback
Are there docs available anywhere that I can review to learn more about this?
I've only been able to find a gist with a basic implementation
https://gist.github.com/yurydelendik/4ae793c1c5cdedf8d35b

I also found this related to this issue:
https://community.spiceworks.com/topic/2080799-how-do-i-make-firefox-respect-default-printer-print-tray-settings

mozPrintCallback is only implemented in Firefox and therefore it only exists in the firefox_print_service.js file. Its objective is to make a higher resolution rendering of the canvas at the resolution of the printer, so it's essentially an API that helps us to print in higher quality. Unfortunately other browsers never implemented this, nor any other decent printing APIs, so printing from JavaScript is therefore very limited in general.

It's difficult to believe that this is still an issue, as significant as it is. I have colleagues who report that this has been a problem for at least 8 years.

I guess we'll instruct our customers to use a different browser to download and print our documents... 👎

It's difficult to believe that this is still an issue, as significant as it is. I have colleagues who report that this has been a problem for at least 8 years.
I guess we'll instruct our customers to use a different browser to download and print our documents... 👎

Yea, it has been happening as long as I can remember, multiple times tickets are opened then closed with no fix, I'm just glad this one is at least being looked at. When Adobe could be used inside as an add-on you could hide the issue since Adobe did the functionality, so we had a work around.

We have the same problem... And the old web applications can't use Adobe....
Any fix in issue ?

Still an issue, one of the most baffling issues in 20 years of IT. How can this not be resolved after 8 years of reporting? I have had to rollback to Chrome in our organisation because of this.

Hello,

Still have this issue with FireFox 78:

ff

My pdf page is in landscape (Paysage in french) :
ff-pdf

but still printing in portrait , any ideas welcome :)

This fix is just merged and not available in Firefox 78 because that released before this fix. It will be in a later Firefox release.

All right ! Thanks @timvandermeij !
Do you know if there is a "public plan" for that merge ? any ideas of which version/date ?

It's most likely going to be in Firefox 80 which is the currently nightly version.

Hallo I use Firefox 81.0.1 (32bit)
Pdf documents landscape in the preview box are not printed in landscape.
I also tried to enable pdfjs.enablePrintAutoRotate but still not work.
Can you help me to fix this please?
Thank you

Hello,
Still have this issue with FireFox 81.0.2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexP3 picture AlexP3  ·  3Comments

SehyunPark picture SehyunPark  ·  3Comments

timvandermeij picture timvandermeij  ·  4Comments

anggikolo11 picture anggikolo11  ·  3Comments

sujit-baniya picture sujit-baniya  ·  3Comments