0

I've seen a couple of topics about this problem - The ability to print through a browser.

Unfortunately the only working solution for me was printing with an iframe. the problem with iframe is that the browser actually hangs quite a bit when the page loads which is a good annoyance.

Is there any other way I can print a file? Should I display it as a html and print it or keep it pdf and use pdfjs to get it in canvas and print?

All of these though don't allow me to set print options, because I'm trying to send it to a label printer it requires specific dimensions.

Thanks in advance,

Sincerely,

  • You cannot print directly to a printer. There is the php.printer extension but I've never got it to work the best you can do is automatically pop up the print window. If you use firefox and setup the printer in the it'll save it as default settings and label size etc so all the user will have to do is hit print but there's no sensible way to automatically do it. Unless you start writing directly to the print spool on a unix machine but that would require the server and printer on the same local network to do it – Dave Apr 12 '13 at 13:12
  • Huh? I don't get your question. Are you developing this web application or simply using it? Normally, users who see a PDF file, will look at it in their favourite PDF reader (e.g. Adobe Reader, pdf.js or Chrome's PDF reader). All of these readers can print out PDFs. And what's that thing with the IFrame? – pvorb Apr 12 '13 at 13:13

2 Answers2

1

The way I solved this is by installing wkhtmltopdf on my server. Since I use a dynamic page with Javascript to add content I send the whole html page to my php wich stores the html file in a temporary folder on my server and then I use wkhtmltopdf to create the pdf. Once thats done my ajax request opens op that new pdf file. and done you can print that pdf.

Its the best solution I found to print out with pdf files, the problem with other things is that you can't get rid of that extra clutter on the top and footer of the webpages.

Greetings Ezeky

Ezeky
  • 36
  • 3
0

In the case of an HTML page : as described here, you can specify css rules for the media type print in your css file. This will be applied when requesting for a print in your browser.

RodolpheChe
  • 599
  • 5
  • 6
  • Thanks guys, I had to go with this. Printing PDF (automatic) is still not possible in this day and age. Fortunately Google's KIOSK features allowed to print HTML without any interaction. I've had to create a markup of the PDF in HTML and use Chrome to print it without interaction. Works really good! – Bob Johnsen Apr 22 '13 at 09:39