0

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?

user2347528
  • 580
  • 1
  • 8
  • 22
  • 1
    Try changing the image src to the relative path of your image folder. Or alternately, can you render the image as Data/URI Base 64? – Batuta Jan 26 '16 at 15:43
  • That worked. Thanks!. I changed the image html to below (base64 string truncated). finalString.Append(@""); – user2347528 Jan 26 '16 at 15:55

1 Answers1

0

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/

user2347528
  • 580
  • 1
  • 8
  • 22