Forum How do I...?

Embed base64 PDF in HTML

Using version Prince 12 attempting to embed a base64 encoded PDF in HTML to be rendered as a PDF along with the rest of the HTML document but prince does not output the PDF data and generates a blank page.

There is no issue with getting the PDF to render correctly in the browser using HTML but any attempt at rendering using prince fails, here are the errors received along with the tags tried - these all work properly when viewing in a browser.

<iframe src="data:application/pdf;base64...." type="application/pdf"></iframe>

Recieve Error : error: Start tag expected, '<' not found

<embed src="data:application/pdf;base64..." type="application/pdf"></object>

prince: debug: loaded resource: type: yes(resource_type("application/pdf", [], unknown, no))
prince: data URL: warning: Unknown image MIME type: application/pdf

<object data="data:application/pdf;base64..." type="application/pdf"></object>

prince: debug: loaded resource: data URL
prince: debug: loaded resource: type: yes(resource_type("application/pdf", [], unknown, no))

Unfortunately Prince cannot embed PDF files within other PDF files at this time.
Hello Mike, Is it likely that Prince will enable PDF embeds? I have three use cases:
1. PhD Dissertation by Publication [i.e., a dissertation with a compilation of published journal articles]. Commentary is provided between the articles.
2. Board of Directors reports [i.e., a compilation of papers; very much used by Company Secretary/CFO roles]
3. Large reports [i.e., a compilation of appendices]
As an interim, I could try using PDF attach, for items 2 and 3, but not for item 1. One of the key problems is that I cannot generate a TOC including the appendices (or embedded file).
At the moment it is necessary to use a separate program such as pdftk to concatenate multiple PDFs. It would be handy to be able to do this in Prince but unfortunately reading PDF files is a significant undertaking.

I stumble across the need for placing PDFs as <img> in PrinceXML almost every single day. The whole printing business (in Germany) rely on PDF as the standard format for logos, graphical work, diagrams, small images for citing a part of a book/journal page inside another publication, etc. – all of those image files are PDFs for getting the best text and graphic output quality.
Since there is no application, which is able to work on SVG in CMYK, there is no print-ready vector format for PrinceXML at the time.

I strongly second the wish to integrate PDF as a possible <img> format for PrinceXML! (Better yesterday than tomorrow ... ;-) )

Thanks, Tobias
One day surely! :D