When including images in the HTML I'm trying to generate a PDF from, only static images will be rendered. For example, I have an image PRD005.png
saved in my project in the ~/Content/Images
folder. Including it as below will render the image in my HTML view and in the PDF file that is generated.
However, when I try to include images from an URL, like from a controller that serves a File
of type image/png
, it will only render in the HTML view, but not in the generated PDF.
Since our images are generated by a Barcode API or read from a BLOB entry in the database, I'd like to find out if it's even possible to render images like this in the generated PDF. If not, is there any work-around to achieve this?
var imagePath = Server.MapPath("~/Content/Images");
<img src="/Barcode/Get/@r.ProductCode" /> // doesn't work
<img src="@imagePath\PRD005.png" /> // works