Embedded base64 pdf won't display in IE when using iframe

大兔子大兔子 提交于 2019-12-06 05:01:23

问题


I wish to display a pdf file which is embedded using base64 encoding in an html. Below is the code I have written for this. The pdf file is displayed in Chrome and firefox but not in Internet Explorer .

Any idea how to get it working in IE? Adobe Reader plugin is properly working in IE for me.

<iframe src="data:application/pdf;base64,baseEncodedString"></iframe>

I am not able to paste the base encoded string because of character limits.But it is of size 401676 characters.


回答1:


Aside from "it" being a terrible solution, here is what I would do:

<iframe src="/unbase64.php?mime=application/pdf&str=baseEncodedString"></iframe>

and then

<?php
header("Content-Type: " . $_GET["mime"]);
echo base64_decode($_GET["str"]);
?>

Stupid and will probably hit the maximum URL length often, but it works in principle.



来源:https://stackoverflow.com/questions/16857678/embedded-base64-pdf-wont-display-in-ie-when-using-iframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!