mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.64k stars 10.01k forks source link

Auto-rotate for printing does not work #9297

Closed timvandermeij closed 4 years ago

timvandermeij commented 6 years ago

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

Configuration:

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):

atensoftware commented 6 years ago

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.

JRC18 commented 6 years ago

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.

sundeepchamarthi commented 5 years ago

Is this issue is fixed or Not ?

shashvat-kedia commented 5 years ago

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

timvandermeij commented 5 years ago

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

beijingalex commented 5 years ago

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

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

dhuang612 commented 5 years ago

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?

JRC18 commented 5 years ago

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.

dhuang612 commented 5 years ago

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

timvandermeij commented 5 years ago

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.

cbj4074 commented 5 years ago

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... 👎

JRC18 commented 5 years ago

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.

cdcstl commented 4 years ago

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

ilium007 commented 4 years ago

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.

JamieKitson commented 4 years ago

@ilium007 See my comment on the other issue.

ilium007 commented 4 years ago

@ilium007 See my comment on the other issue.

See my response here: https://github.com/mozilla/pdf.js/issues/6696#issuecomment-638156741

JeanMarieMace commented 4 years ago

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 :)

timvandermeij commented 4 years ago

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.

JeanMarieMace commented 4 years ago

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

timvandermeij commented 4 years ago

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

stexyn commented 4 years ago

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

stexyn commented 4 years ago

Hello, Still have this issue with FireFox 81.0.2

tlissak commented 3 years ago

Hello In firefox 85.0 pdfjs.enablePrintAutoRotate in about:config Do rotate de page automaticly, This parameter (pdfjs.enablePrintAutoRotate=true ) should be activate by default as other modern browsers.