X
Tap here to go to the mobile version of the site.

Support Forum

Embedded PDF viewer to printer changes the PDF format

Posted

I need help with the embedded PDF Viewer. When printing a pdf generated from a web app (SAP Fiori), it's orientation, format all of it's parameters are not pass to the printer. The same PDF when saved locally, opened in Adobe Reader prints fine. Same with chrome. Also, when previewing the file in embedded viewer, the orientation and format are correct.

Other interesting stuff, I found out that Firefox is keeping a trace of some of the printer's parameters that are define in the driver ( I think). So, if a printer's driver is set to be A4, Portrait, this parameters are kept in Firefox and are applied to the file it's printing.

If anyone has some hint or guidelines, i'd appreciate a lot. Thanks ! Has someone ever had an issue with that ?

I need help with the embedded PDF Viewer. When printing a pdf generated from a web app (SAP Fiori), it's orientation, format all of it's parameters are not pass to the printer. The same PDF when saved locally, opened in Adobe Reader prints fine. Same with chrome. Also, when previewing the file in embedded viewer, the orientation and format are correct. Other interesting stuff, I found out that Firefox is keeping a trace of some of the printer's parameters that are define in the driver ( I think). So, if a printer's driver is set to be A4, Portrait, this parameters are kept in Firefox and are applied to the file it's printing. If anyone has some hint or guidelines, i'd appreciate a lot. Thanks ! Has someone ever had an issue with that ?
Quote

Additional System Details

Application

  • User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0

More Information

Question owner

The problem isn't related to SAP Fiori. I tried with a random PDF that is set to landscape orientation : https://www.wpi.edu/sites/default/files/docs/Events/Annual-Events/landscape.pdf Printing it from Firefox embeded viewer passes it to the printer in portrait. When printing from any other pdf viewer, it's printing in landscape.

I'm not a developper, I do not know how to generate a PDF using any available tools out there, but something I realize is if I save the pdf file from the firefox embeded viewer and open it in a text editor, the header and footer are formated differently than doing the same thing in adobe reader per exemple.

The problem isn't related to SAP Fiori. I tried with a random PDF that is set to landscape orientation : https://www.wpi.edu/sites/default/files/docs/Events/Annual-Events/landscape.pdf Printing it from Firefox embeded viewer passes it to the printer in portrait. When printing from any other pdf viewer, it's printing in landscape. I'm not a developper, I do not know how to generate a PDF using any available tools out there, but something I realize is if I save the pdf file from the firefox embeded viewer and open it in a text editor, the header and footer are formated differently than doing the same thing in adobe reader per exemple.
Was this helpful to you?
Quote
jscher2000
  • Top 10 Contributor
8695 solutions 71066 answers

Hi Jonathan, I don't think Firefox automatically rotates from Portrait to Landscape, or detects the PDF paper size, for printing. You can select the correct orientation using the Print Preview screen. Instead of using Ctrl+p, call up preview using either:

  • "3-bar" menu button > Print
  • (menu bar) File > Print Preview

Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) You can use the download button on the viewer's black toolbar for that:

Hi Jonathan, I don't think Firefox automatically rotates from Portrait to Landscape, or detects the PDF paper size, for printing. You can select the correct orientation using the Print Preview screen. Instead of using Ctrl+p, call up preview using either: * "3-bar" menu button > Print * (menu bar) File > Print Preview Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) You can use the download button on the viewer's black toolbar for that: <img src="https://user-media-prod-cdn.itsre-sumo.mozilla.net/uploads/images/2019-07-10-10-45-38-1540ed.png" width="500">
Was this helpful to you?
Quote

Question owner

jscher2000 said

Hi Jonathan, I don't think Firefox automatically rotates from Portrait to Landscape, or detects the PDF paper size, for printing. You can select the correct orientation using the Print Preview screen. Instead of using Ctrl+p, call up preview using either:
  • "3-bar" menu button > Print
  • (menu bar) File > Print Preview
Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) You can use the download button on the viewer's black toolbar for that:

Sadly this cannot be done. We try to configure Firefox in a way that the end user doesn't need to manually changes some parameters to achieve their daily tasks. Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer.

Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ?

''jscher2000 [[#answer-1236736|said]]'' <blockquote> Hi Jonathan, I don't think Firefox automatically rotates from Portrait to Landscape, or detects the PDF paper size, for printing. You can select the correct orientation using the Print Preview screen. Instead of using Ctrl+p, call up preview using either: * "3-bar" menu button > Print * (menu bar) File > Print Preview Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) You can use the download button on the viewer's black toolbar for that: <img src="https://user-media-prod-cdn.itsre-sumo.mozilla.net/uploads/images/2019-07-10-10-45-38-1540ed.png" width="500"> </blockquote> Sadly this cannot be done. We try to configure Firefox in a way that the end user doesn't need to manually changes some parameters to achieve their daily tasks. Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer. Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ?
Was this helpful to you?
Quote
jscher2000
  • Top 10 Contributor
8695 solutions 71066 answers

Helpful Reply

jonathan.gaudreau said

jscher2000 said
Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.)

Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer.

The user can click the button, you don't need to change the default setting. But I get that you think this would be too difficult for your users. As an alternative, how about serving those PDFs with content-disposition: attachment to bypass the built-in viewer and pop up the download dialog?

Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ?

The built-in version of the viewer is considered protected browser code and can't be modified by extensions. If you host the viewer on your server and load the PDF into it, you can modify the viewer. It's open source:

However, overriding Firefox's printing behavior is probably beyond the scope of a web page. For example, you could add a rule to rotate PDFs, but if the user has the default value of Shrink to Fit, it will be too small (the scaling is calculated before the rotation is applied).

@media print {
  /* Rotate letter size landscape PDF page for 
     printing on portrait paper; assumes:
     letter size output, 100% scaling */
  body {
    transform: rotate(-90deg) translate(-11in, 0);
    transform-origin: 0 0;
  }
}
''jonathan.gaudreau [[#answer-1236769|said]]'' <blockquote> ''jscher2000 [[#answer-1236736|said]]'' <blockquote> Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) </blockquote> Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer. </blockquote> The user can click the button, you don't need to change the default setting. But I get that you think this would be too difficult for your users. As an alternative, how about serving those PDFs with content-disposition: attachment to bypass the built-in viewer and pop up the download dialog? * Example: https://www.jeffersonscher.com/res/servepdf.php?f=Mixed_Content_Blocking.pdf * PHP Code: https://www.jeffersonscher.com/res/servepdf.php (this can be done in any server-side language; there's probably an easier way) <blockquote> Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ? </blockquote> The built-in version of the viewer is considered protected browser code and can't be modified by extensions. If you host the viewer on your server and load the PDF into it, you can modify the viewer. It's open source: * Demo: https://mozilla.github.io/pdf.js/web/viewer.html * Code: https://github.com/mozilla/pdf.js/ However, overriding Firefox's printing behavior is probably beyond the scope of a web page. For example, you could add a rule to rotate PDFs, but if the user has the default value of Shrink to Fit, it will be too small (the scaling is calculated before the rotation is applied). <pre>@media print { /* Rotate letter size landscape PDF page for printing on portrait paper; assumes: letter size output, 100% scaling */ body { transform: rotate(-90deg) translate(-11in, 0); transform-origin: 0 0; } } </pre>
Was this helpful to you? 2
Quote

Question owner

Great information! jscher2000 said

jonathan.gaudreau said
jscher2000 said
Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.)

Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer.

The user can click the button, you don't need to change the default setting. But I get that you think this would be too difficult for your users. As an alternative, how about serving those PDFs with content-disposition: attachment to bypass the built-in viewer and pop up the download dialog?

Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ?

The built-in version of the viewer is considered protected browser code and can't be modified by extensions. If you host the viewer on your server and load the PDF into it, you can modify the viewer. It's open source:

However, overriding Firefox's printing behavior is probably beyond the scope of a web page. For example, you could add a rule to rotate PDFs, but if the user has the default value of Shrink to Fit, it will be too small (the scaling is calculated before the rotation is applied).

@media print {
  /* Rotate letter size landscape PDF page for 
     printing on portrait paper; assumes:
     letter size output, 100% scaling */
  body {
    transform: rotate(-90deg) translate(-11in, 0);
    transform-origin: 0 0;
  }
}

Great information you just shared. I'll pass along these informations to our project team and see what they achieve with what you just shared.

Thank you!

Great information! ''jscher2000 [[#answer-1236798|said]]'' <blockquote> ''jonathan.gaudreau [[#answer-1236769|said]]'' <blockquote> ''jscher2000 [[#answer-1236736|said]]'' <blockquote> Actually, I generally recommend printing PDFs from your stand-alone PDF program because you often get better fidelity. (Firefox converts the PDF to HTML to display it.) </blockquote> Also, changing the default pdf application to Adobe reader will impact another system that works great with the embeded viewer. </blockquote> The user can click the button, you don't need to change the default setting. But I get that you think this would be too difficult for your users. As an alternative, how about serving those PDFs with content-disposition: attachment to bypass the built-in viewer and pop up the download dialog? * Example: https://www.jeffersonscher.com/res/servepdf.php?f=Mixed_Content_Blocking.pdf * PHP Code: https://www.jeffersonscher.com/res/servepdf.php (this can be done in any server-side language; there's probably an easier way) <blockquote> Is there a way for a developer to mess with the pdf.js so that the embeded viewer does not interfer with the original format of a pdf ? </blockquote> The built-in version of the viewer is considered protected browser code and can't be modified by extensions. If you host the viewer on your server and load the PDF into it, you can modify the viewer. It's open source: * Demo: https://mozilla.github.io/pdf.js/web/viewer.html * Code: https://github.com/mozilla/pdf.js/ However, overriding Firefox's printing behavior is probably beyond the scope of a web page. For example, you could add a rule to rotate PDFs, but if the user has the default value of Shrink to Fit, it will be too small (the scaling is calculated before the rotation is applied). <pre>@media print { /* Rotate letter size landscape PDF page for printing on portrait paper; assumes: letter size output, 100% scaling */ body { transform: rotate(-90deg) translate(-11in, 0); transform-origin: 0 0; } } </pre> </blockquote> Great information you just shared. I'll pass along these informations to our project team and see what they achieve with what you just shared. Thank you!
Was this helpful to you?
Quote
Ask a question

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.