javascript - pdf 使用嵌入标签时,为什么打印屏幕上出现空白页?
问题描述
我想使用嵌入标签打印 PDF。PDF 出现在屏幕上,但空白页出现在打印屏幕上。为什么?我该如何解决这个问题?
const width = window.innerWidth * 0.9;
const height = window.innerHeight * 0.9;
const content = `<!DOCTYPE html>
<html>
<head><title></title></head>
<body onload="window.focus(); window.print(); window.close();">
<embed width="720" height="540" src="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" />
</body>
</html>`;
const options = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=' + width + ',height=' + height;
const printWindow = window.open('', 'print', options);
printWindow.document.open();
printWindow.document.write(content);
printWindow.document.close();
printWindow.focus();
解决方案
推荐阅读
- ignite - 在 Cassandra 中点燃获取列映射类型
- vue.js - 如何在 Nativescript-Vue 中执行 Google API?
- java - 在java应用程序中读取xml文档
- android - 谷歌地图过渡
- python - 从系列中减去一个数据框(或其唯一的列)
- python - 在kivy上实现pywebview
- vb.net - 在 VB.Net 应用程序的第 40 次迭代中,底层连接被关闭
- python - 如何使用 python 或 mql5 从 IQO 二进制交易室中抓取每个分时数据?
- sql - 用于选择数据库中所有 pk/fk 的 SQL 查询
- php - 以编程方式删除 core_url_rewrite 条目 magento