How to print a PDF file using javascript
<p>I'm trying to have a link which open up a print preview for a PDF (the PDF is placed near the actual .html page)</p>

<p>I've tried:</p>

<pre><code>&lt;script&gt;
function printpdf()
{
    var w = window.open('example.pdf');

    w.onload = function()
    {
        w.print();
    };
}
&lt;/script&gt;
</code></pre>

<p>but it doesn't fire the browser print page. However, the PDF opens up</p>

<p>I also tried the JQuery approach:</p>

<pre><code>&lt;script&gt;
function printpdf()
{
    var w = window.open('example.pdf');

    $(w).ready(function(){
        w.print();
    });
}
&lt;/script&gt;
</code></pre>

<p>no luck. The PDF opens but the print preview is not triggered.</p>

<p>What I am missing here?</p>