[英]Open a file in a print window by getting the file from the file url specified
我正在尝试使用jQuery
在我的应用程序中实现打印选项。 我将要打印url of the file
的url of the file
作为<a> tag
的src
属性。 我要做的就是从指定的url中获取文件,然后在用户可以从中打印文件的打印窗口中将其打开。 我使用的代码如下:
<a id="print-5569" href="http://www.ibiblio.org/ebooks/Baum/Santa_Claus.pdf "><i class="fa fa-download"></i></a>
我尝试了许多在线找到的解决方案,但注意到对我有用。 我尝试过的示例之一是以下示例: https : //www.sitepoint.com/load-pdf-iframe-call-print/
当我在线搜索时,我会为此找到插件。 但我不想为此添加插件。 有什么解决办法吗?
如果pdf存储在同一域中,则可以执行以下操作:
document.getElementById('print-5569').addEventListener('click', () => {
var w = window.open('http://www.ibiblio.org/ebooks/Baum/Santa_Claus.pdf');
w.print();
});
否则,您可以将此方法与在相同域上运行的简单pdf代理类型的事物配对,例如google drive。 (例如https://drive.google.com/viewerng/viewer?url=http://www.ibiblio.org/ebooks/Baum/Santa_Claus.pdf )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.