pdf 未嵌入 html IE11

pdf not getting embedded in html IE11

我想将 base64 编码的 pdf 字符串嵌入到 html 模板中。 <iframe src="data:application/pdf;base64, encodeURI(pdfstring)"></iframe> 这在 chrome 和 edge 中工作正常但在 IE 中显示空白页 11.I 不想下载 it.Is IE11

有一个修复

它不起作用,因为 IE 不支持将数据 url 作为 src 属性的 iframe。您可以在 caniuse. It shows that the support is limited to images and linked resources like CSS or JS in IE. Please also check this documentation:

中查看

Data URIs are supported only for the following elements and/or attributes.

  • object (images only)
  • img
  • input type=image
  • link
  • CSS declarations that accept a URL, such as background, backgroundImage, and so on.

你只能按照 accepted answer 所说的去做:

The only workaround for this is to return your PDF content from a HTTP/HTTPS or FTP URI and use that as the source of the IFRAME.