HTML

Inline PDF in HTML Page

Data URI scheme works not only with images.

You can even print inline pdfs with code like that:

<embed src="data:application/pdf;base64,<?=base64_encode($pdfBody)?>" width="800" height="600"/>

This code is handy when you need to print a pdf file that is not accessible via HTTP. I use it on debug page of scraper that downloads pdf files to system temp dir.

By the way, PHP allows this scheme too. Here's the manual about it. It is sometimes useful when you're unit testing functions that read data from files.


Tags: , ,

Comments