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 very useful when you need to print 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 such scheme too. Here's the manual about it. This is somenimes useful when you're unit testing functions that read data from file.

Tags: , ,