Embedded base64 pdf won't display in IE when u

2020-07-19 23:41发布

问题:

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.