javascript - 我可以自动将 pdf 文件发送到打印机吗?

标签 javascript

我有以下内容:

<iframe src="ACRBusinessCL.pdf" id="PDFtoPrint" height="800" width="800">
</iframe>
<form>
<input type="button" value="Print" onclick="document.getElementById('PDFtoPrint').focus(); document.getElementById('PDFtoPrint').contentWindow.print();">
</form>

让我发疯的是:我以为我曾经有过这个工作。 pdf 文件显示在 iframe 中,但是当我单击“打印”时,没有任何反应。

最佳答案

<script type="text/javascript">
    function printPage(yoururl) {
            var w = window.open(yoururl);
            w.document.write(yoururl);
            w.print();
    }

</script>

关于javascript - 我可以自动将 pdf 文件发送到打印机吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6145037/

相关文章:

javascript - 在不使用 id 选择器的情况下切换多个 MaterializeCSS 图标

javascript - TypeScript - 如何使用数组映射到 ES 6 映射?

javascript - 链接 promise 和传递值的简洁方式

php - 在 javascript/HTML5 应用程序之外获取变量

javascript - 在输入字段中输入乘法或除法,即可对其他 2 个输入字段执行乘法或除法

javascript - Webpack/Babel 未删除 "const"

javascript - 防止 ModalDialog 格式化我的字符串

JavaScript:如何将字典变成元素列表?

javascript - 如果源代码被更改,则重定向

JavaScript 电子邮件验证 - @ 之前的字符串变量