Can a PDF be MIME encoded and included as part of the payload of an HTML page? This site shows that you can include a MIME-encoded image or a CSS in an HTML page: http://www.greywyvern.com/code/php/binary2base64/ -- but I don't know what the markup would be for an encoded PDF included in an HTML page. Thanks.
Asked
Active
Viewed 5.5k times
25
-
Why don't you try it `data:application/pdf;base64,base64encodedpdf`, also what tag would you put it in? – Musa Jul 18 '12 at 22:21
-
Checkout this question and accepted answer http://stackoverflow.com/questions/291813/best-way-to-embed-pdf-in-html – Jorge Ferreira Jul 18 '12 at 22:24
1 Answers
33
I've tried it with iframe
and embed
, worked in chrome, opera and safari, no ie or ff
<iframe src="data:application/pdf;base64,base64encodedpdf"></iframe>
<embed src="data:application/pdf;base64,base64encodedpdf">
http://jsfiddle.net/yLx2W/
http://jsfiddle.net/yLx2W/1/
Maybe with some tweaking you can get them to work for ff and maybe ie.

Musa
- 96,336
- 17
- 118
- 137
-
3
-
3UPDATE: As of April 2021, `iframe` works in Chrome but `embed` does not. – JeremyW Apr 02 '21 at 18:31
-