<分区>
我希望在用户单击特定链接时在客户端打印 PDF。但是,不应打开 PDF 并且应该触发打印。它可能不是静默打印,可能会出现一个要求打印机使用的操作系统弹出窗口。我的 PDF 阅读器应该是 Adobe Reader。 我找到了很多链接来尝试,但是发现它们依赖于所使用的浏览器。我试过这段代码在 Chrome 中成功打印,但我认为 chrome 有自己的 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>
非常感谢任何帮助。