3
我希望在用户点击特定链接时在客户端打印PDF。但是,PDF不应该打开并打印。它可能不是静音打印,要求打印机使用的操作系统弹出窗口可以来。我的PDF阅读器应为Adobe Reader。 我发现了很多链接,试图发现它们依赖于正在使用的浏览器。我试过这段代码能够在Chrome中成功打印,但我认为chrome有自己的PDF渲染器。在客户端浏览器打印PDF而不打开PDF
<script>function iprint(ptarget){
ptarget.focus();
ptarget.print();
}
</script><body>
<iframe name="theiframe" id="theiframe" width="500" height="200" src="http://192.168.108.105:8081/PDfTest/Excel.pdf" style="display:none">
</iframe>
<input type="button" value="print iframe" onclick="iprint(theiframe);" />
</body>
也试过这个代码块,但这打开PDF,然后打印:
<html>
<script language="javascript">
timerID = setTimeout("exPDF.print();", 1000);
</script>
<body>
<object id="exPDF" type="application/pdf" data="111.pdf" width="100%" height="500"/>
</body>
</html>
希望得到任何帮助。