evopdf 6.12; html string to pdf, does not render image on the pdf

1.2k Views Asked by At

I am trying to use EvoPdf library (demo version). I have html string with a full path to an image for example:

finalString.Append(@"<img src='http://www.ladessertelocale.com/2618-home_default/tomate-bio-1-kg.jpg'/>");  

I used the following code to generate the pdf. The pdf file is generated with all the content but the image does not show on the pdf generated. A red x is shown in place of the image.

HtmlToPdfConverter converter = new HtmlToPdfConverter{
LicenseKey = "",
HtmlViewerWidth = 1024,
PdfDocumentOptions = { PdfPageSize = PdfPageSize.A4, PdfPageOrientation = PdfPageOrientation.Portrait, InternalLinksEnabled = true }
};
byte[] outPdfBuffer = null;
outPdfBuffer = converter.ConvertHtml(finalString.ToString(), "");
return File(outPdfBuffer, "application/pdf");

Am I missing something?

1

There are 1 best solutions below

0
On

As suggested by Batuta, I changed the image html to below (base64 string truncated).

finalString.Append(@"<img src='data:image/png;base64,iVBORw0KGgSAGXR'/>");

I used this website to upload the image and get base64 string representation of the image. http://imagetobase64.com/