How to send a pdf file directly to the printer using JavaScript?

I think this Library of JavaScript might Help you:

It’s called Print.js

First Include

<script src="https://stackoverflow.com/questions/7074070/print.js"></script>
<link rel="stylesheet" type="text/css" href="print.css">

It’s basic usage is to call printJS() and just pass in a PDF document url: printJS('docs/PrintJS.pdf')

What I did was something like this, this will also show “Loading….” if PDF document is too large.

<button type="button" onclick="printJS({printable:'docs/xx_large_printjs.pdf', type:'pdf', showModal:true})">
    Print PDF with Message
</button>

However keep in mind that:

Firefox currently doesn’t allow printing PDF documents using iframes. There is an open bug in Mozilla’s website about this. When using Firefox, Print.js will open the PDF file into a new tab.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)