Java 在客户端浏览器中打印PDF而不打开PDF
我希望在用户单击特定链接时在客户端打印PDF。但是,PDF不应打开,应启动打印。它可能不是静默打印,操作系统弹出窗口要求打印机使用。我的PDF阅读器应该是Adobe Reader。 我找到了很多链接,但是发现它们依赖于所使用的浏览器。我试着在Chrome中成功地打印出这段代码,但我认为Chrome有自己的PDF渲染器Java 在客户端浏览器中打印PDF而不打开PDF,java,javascript,pdf,cross-browser,Java,Javascript,Pdf,Cross Browser,我希望在用户单击特定链接时在客户端打印PDF。但是,PDF不应打开,应启动打印。它可能不是静默打印,操作系统弹出窗口要求打印机使用。我的PDF阅读器应该是Adobe Reader。 我找到了很多链接,但是发现它们依赖于所使用的浏览器。我试着在Chrome中成功地打印出这段代码,但我认为Chrome有自己的PDF渲染器 <script>function iprint(ptarget){ ptarget.focus(); ptarget.print();
<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>
函数iprint(ptarget){
ptarget.focus();
ptarget.print();
}
还尝试了此代码段,但这会打开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>
timerID=setTimeout(“exPDF.print();”,1000);
非常感谢您的帮助。您是否可以打开PDF,但打开的方式用户看不见?如果是这样,您可以使用