I want to trigger the print of a PDF file which I load in and iframe.
After looking around, I came up with the following bit
<iframe name="pdfname" id="pdfid"></iframe>
<button id="printbtn">Print</button>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#pdfid").load(function() {
window.frames["pdfname"].focus();
window.frames["pdfname"].print();
});
$("#printbtn").click(function () {
$("#pdfid").attr("src", '@Url.Action("PdfTest", "Home")');
});
});
</script>
This works perfectly in Chrome.
In Firefox, I get the following error (I read somewhere it was a bug that was supposed to be fixed in version 21, but it wasn't)
Permission denied to access property 'print'
In Internet Explorer 10 and 9, I get the following error
Invalid calling object
which seems to point to the PDF generated by my MVC action.
I've seen numerous posts with problems similar to mine, yet haven't come across a working solution so far.
What I would really want to know is how RADPDF managed to get this working in every browser
Click the print button on this page
I know this can be done, I need help from you brains out there!
Cheers
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…