HTML-Renderer icon indicating copy to clipboard operation
HTML-Renderer copied to clipboard

Problem render pages to pdf with images

Open AndGutierrez opened this issue 6 years ago • 1 comments

I'm trying to render html body from email (MimeKit) that contains an embededs images.

I test two ways:

  • Changing the attribute img src to "file://" that are locate in an existing local path. For this case, trying to see the html when I paste the html code it makes an error with the image.
  • Changing the attribute img src to "data:image" and pasting the string for the bytes[] decoded. In this case it works and I can see the html but I can't create the pdf because there is an error creating the pdfdocument with this image.

Regards, Andrews

AndGutierrez avatar Jan 29 '19 09:01 AndGutierrez

I have done exactly what you are trying to do. I started out saving the images locally and using file:// references. Works OK but some browsers don't allow local file access so you may not see the images if you're opening the HTML to preview it during your development/testing. Later I took the other approach: replacing the img src references with data URIs (embedding the image inline as data). I did that mainly so the HTML document would be portable as Chrome doesn't support MHT/MHTML very well. Both approaches work fine for generating PDF using HtmlRenderer.PdfSharp. What specific error are you getting?

bradleypeet avatar Mar 19 '19 20:03 bradleypeet