0

In my web app users can either "print" a report or "pdf" a report by clicking one of two buttons. Now I've set up the PDF button to generate a PDF using mPDF and it works ok for some reports but it doesn't support a lot of different CSS so in a lot of cases it pretty much sucks balls.

I don't know how the "Save as PDF" or "Microsoft Print to PDF" drivers do it but those drivers work perfectly. So what I'd like to do is, instead of trying to generate my own PDF, I'd like to just open the print preview in the browser with "Save as PDF" (or some other PDF driver) pre-selected. Is this possible?

I know that print() function does not take any parameters but I know I'm not the first to fiddle with this kind of thing so I'm hoping somebody has come up with a creative solution to achieve good results.

I'm not looking to bypass the print dialog or the print preview as other questions I've seen on StackOverflow. I just want to pre-select the printer for the user if possible.

I'm using PHP, Javascript, jQuery.

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
Vincent
  • 1,741
  • 23
  • 35
  • 1
    Setting a printer isn't possible. There are other ways to create PDFs though. I use [fPDF](http://www.fpdf.org/), a PHP library for creating PDF files from scratch. –  Jan 28 '19 at 18:44

0 Answers0