首页 > 解决方案 > PDF打印对话框获取空白页

问题描述

我正在尝试使用window.print()在浏览器上打印以前流式传输的 PDF 文档。

文档已加载,但是当我使用 windows.print() ( ctrl+P ) 绑定打印时,我在预览时得到空白页

我试图穿上iframe嵌入或更改样式、大小......但我总是得到空白页。 空白打印[1]

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);   }

标签: javascriptangulartypescriptpdfprinting

解决方案


推荐阅读