Html 如何在angular 6组件中嵌入数据(PDF Base 64)

Html 如何在angular 6组件中嵌入数据(PDF Base 64),html,angular,embed,Html,Angular,Embed,在angular 6中的应用程序中,我在新窗口中显示数据(报告),如下所示。 ***结果包含Base64数据*** if (result != null) { const pdfWindow = window.open(""); pdfWindow.document.write("<html<head><title>Pathology Report</title><

在angular 6中的应用程序中,我在新窗口中显示数据(报告),如下所示。 ***结果包含Base64数据***

if (result != null) {    
          const pdfWindow = window.open("");    
          pdfWindow.document.write("<html<head><title>Pathology Report</title><style>body{margin: 0px;}iframe{border-width: 0px;}</style></head>");    
          pdfWindow.document.write("<body><embed width='100%' height='100%' src='data:application/pdf;base64, " +    
              encodeURI(result) + "#toolbar=0&navpanes=0&scrollbar=0'></embed></body></html>")   
但它显示了错误“在资源URL上下文中使用了不安全的值”。 结果在新窗口中正确显示,但当尝试嵌入时,显示错误。 如何嵌入数据。我的数据也是base64。

出什么事了?任何帮助都将不胜感激。谢谢。

请添加数据:application/pdf;base64,在base64字符串之前

<iframe [src]="data:application/pdf;base64, PathReportString"></iframe>

它可以工作。我在.html文件中编写了如下代码

 <iframe id="ifrm" style="width: 100%; height: 100%;"></iframe>

它显示了错误。“求值不支持引号!语句:application/pdf;base64,PathReportString”PathReportString是base64字符串吗?我明白了,请在双引号之间添加单引号。请添加数据:application/pdf;base64,在base64字符串按您所说的那样尝试之前。显示错误“资源URL上下文中使用了不安全的值”
<iframe [src]="data:application/pdf;base64, PathReportString"></iframe>
 <iframe id="ifrm" style="width: 100%; height: 100%;"></iframe>
 this.PathReportString = 'data:application/pdf;base64,' + (this.sanitizer.bypassSecurityTrustResourceUrl(result) as any).changingThisBreaksApplicationSecurity;
      
top.document.getElementById('ifrm').setAttribute("src", this.PathReportString);