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)
I've tried:
<script>
function printpdf()
{
var w = window.open('example.pdf');
w.onload = function()
{
w.print();
};
}
</script>
but it doesn't fire the browser print page. However, the PDF opens up
I also tried the JQuery approach:
<script>
function printpdf()
{
var w = window.open('example.pdf');
$(w).ready(function(){
w.print();
});
}
</script>
no luck. The PDF opens but the print preview is not triggered.
What I am missing here?