html:print()嵌入文件 [英] html: print() embed file
本文介绍了html:print()嵌入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下内容在html中显示pdf:
I am showing a pdf inside a html using:
<embed id="print" src="file.pdf" type="application/pdf" width="100%" height="100%">
我想创建一个打印该文件的按钮。
I would like to create a button that prints that file.
我认为这会是这样的;但它不起作用。
I thought it would be something like this; but it isn't working.
<button onClick="javascript:document.getElementById('print').print();">
任何人都知道如何在嵌入文件中调用打印函数吗?
Anybody an idea how I can call the print function on an embedded file?
推荐答案
<script type="text/javascript">
function printPDF(pdfUrl)
{
var w = window.open(pdfUrl);
w.print();
}
</script>
您可以调用 printPDF(http://mywebsite.com /myfile.pdf)
这篇关于html:print()嵌入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文