Forum How do I...?

Embed arbitrary images.

Jonathan2357
I have a situation where I want to generate a PDF of a report that has some images embedded inside of it. The trick is that these images are encrypted and stored on amazon. So, we have a bit of code that pulls it down and decrypts (and also does some other minor postprocessing), and it works just fine when sending to a browser.

However, the only way I know of (I'm sure this is more due to my ignorance than anything) to get Prince to run on an image is to include it from an HTML <img> tag or from CSS: url. These both seem to want to accept absolute file paths as parameters, and that makes it a bit clunky to work with when the image is dynamically generated. Is there any way to include the image content directly into the HTML?

About formats, the generated image can be in any format really, since it's dynamic, so I'm a bit flexible there. The only thing its that it is NOT a vector based image, so SVG seems to be a no-go.
mikeday
Prince can use data URLs, so you could embed the image that way. But how are you embedding it in the browser? If you are using JavaScript, perhaps that can work in Prince as well. Are you running Prince with --javascript enabled?
Jonathan2357
Data URLs are a possibility I didn't know existed. I assume you can specify an HTTP url? Is it possible to post a link to a small example? (Can't seem to find one in the docs, but maybe I missed it)

Sorry about the slow response, I got a little distracted by other stuff.
mikeday
Yes of course, HTTP URLs work fine for images, and other resources. Just use them the normal way:
<img src="http://example.com/blah/image.jpg"/>