根据以下评论,它不再可在现代浏览器中使用。
该问题演示了一种可能对您有所帮助的方法:静默打印嵌入式PDF
它使用
<embed>标签将PDF嵌入文档中:
<embed type="application/pdf" src="path_to_pdf_document.pdf" id="pdfdocument" width="100%" height="100%" />
然后,
.print()在加载PDF时,在Javascript中的元素上调用方法:
function printdocument(documentId) { var doc = document.getElementById(documentId); //Wait until PDF is ready to print if (typeof doc.print === 'undefined') { setTimeout(function(){printdocument(documentId);}, 1000); } else { doc.print(); }}您可以将嵌入内容放置在隐藏的iframe中,然后从那里进行打印,从而获得无缝的体验。



