I need to print a .pdf file (I generate it with jasperReport and I save it on a server) when I click on a print.gif button. Now I found this solution that works for Firefox
Create a iframe
in html:
<iframe id="pdf-iframe">
Then change the src
of that iframe
and on load
, print it.
$('#pdf-iframe').attr("src", pdf_url).load(function(){
document.getElementById('pdf-iframe').contentWindow.print();
});
I believe the Problem is that the content is not loaded yet? I had the same issue in IE8. I had to save the document, reopen it, print, and close the window again.