使用Web应用程序打印pdf [关闭]

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,

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.

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