Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIME encoding of a PDF file in an HTML page

Tags:

html

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.

like image 921
user1536245 Avatar asked Jul 18 '12 22:07

user1536245


People also ask

How do I code a PDF in HTML?

The easiest way to put PDF in an HTML document is using the <a> tag with its href attribute. You need to add the URL or the reference link of your PDF file to the element.

Can you Base64 encode a PDF?

Base64 encoding is used to encode binary data, such as a PDF file, into an ASCII string format that is compatible with systems that can only handle text. For example, email attachments and binary uploads in HTML forms are converted and transmitted as Base64 encoded data.

Can you embed a PDF in a Web page?

Fortunately, Adobe has released Adobe PDF Embed API (PDF Embed), an easy way for you to incorporate a PDF directly into your website with just an easy snippet of code. It is entirely free to use and renders client-side within your web app. You don't have to learn a sophisticated PDF library, and it is super easy to do.


1 Answers

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.

like image 129
Musa Avatar answered Oct 19 '22 17:10

Musa