javascript - PDF打印对话框获取空白页
问题描述
我正在尝试使用window.print()在浏览器上打印以前流式传输的 PDF 文档。
文档已加载,但是当我使用 windows.print() ( ctrl+P ) 绑定打印时,我在预览时得到空白页
我试图穿上iframe并嵌入或更改样式、大小......但我总是得到空白页。
getPDF(pdfID: string) {
var winparams = 'dependent=yes,locationbar=no,scrollbars=yes,menubar=yes,' >
var printWindow = window.open("", "", winparams);
var htmlPop;
this.rs.grps(reportId).subscribe(
(response) => {
this.pdfSrc = "data:application/pdf;base64," + response;
debugger;
setTimeout(() => {
htmlPop = '<embed style="display:block !important" width=100% height=100%'
+ ' type="application/pdf"'
+ ' src="'
+ this.pdfSrc
+ '"></embed>';
printWindow.document.write(htmlPop);
//window.print();
}, 1000);
}
);
setTimeout(() => {
printWindow.print();
printWindow.close();
}, 5000); }
解决方案
推荐阅读
- sql - 在 SQL 中查找实体的第一个和最后一个条目的最有效方法是什么?
- unicode - CQL 转义 \xa0
- sql-server - 如何将变量分配给存储过程的执行?
- cuda - CUDA 中的条件复制,其中数据向量比模板长
- vue.js - 在条件语句中使用 Vue.js 过滤器
- javascript - 函数不能被多次调用
- c# - 达到零后无法进行计时器循环
- jquery - Jquery Mobile 页面、输入字段、固定页脚和键盘隐藏
- ruby-on-rails - 如何在不迭代的情况下从查询中检查 ActiveRecord 的存在?
- intellij-idea - 如何使用 JavaFX 框架?