I am able to use javascript to print PDF file in Internet Explorer and Firefox, as such:
<script type="text/javascript">
<!--
if (navigator.appName == 'Microsoft Internet Explorer')
{
document.write('<object id="agreementPDF" type="application/pdf" data="file.pdf" width="100%" height="500"></object>');
}
else
{
document.write('<iframe id="agreementFrame" src="file.pdf" width="100%" height="500px"></iframe>');
}
//-->
</script>
<script type="text/javascript">
<!--
function printAgreement()
{
if (navigator.appName == 'Microsoft Internet Explorer')
{
document.getElementById('agreementPDF').print();
}
else
{
var agreement = document.getElementById('agreementFrame');
agreement.focus();
agreement.contentWindow.print();
}
}
//-->
</script>
<input type="button" name="print" onclick="printAgreement();" value="Print" />
However, in Opera, the print function does not work.
How do I make it work?
Thanks.