This project is read-only.

Images don't display in PDF

Jan 18, 2017 at 10:28 PM
Edited Jan 18, 2017 at 10:28 PM
I have a fairly simple HTML page rendered via It look beautiful in the PDF after running it through HtmlRenderer.PdfSharp EXCEPT that the images don't appear. Just the red X of a missing image in the PDF even though the web page itself does display the image correctly.

Here is my HtmlRenderer.PdfSharp code:
public void BuildPDF( string url, string pdfPath ) {
   string html = GetHTML(url);
   Byte[] res = null;
   using( MemoryStream ms = new MemoryStream() ) {
      using( FileStream file = new FileStream(pdfPath, FileMode.Create, FileAccess.Write) ) {
         byte[] bytes = new byte[ms.Length];
         var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);
         res = ms.ToArray();
         file.Write(res, 0, res.Length);

private string GetHTML(string url) {
   string html = string.Empty;
   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
   request.AutomaticDecompression = DecompressionMethods.GZip;

   using( HttpWebResponse response = (HttpWebResponse)request.GetResponse() )
   using( Stream stream = response.GetResponseStream() )
   using( StreamReader reader = new StreamReader(stream) ) {
      html = reader.ReadToEnd();

   return html;
And here is the img html that doesn't render in the PDF: <img src="images/ChartImg.png" />

How can I solve this?
Jan 20, 2017 at 4:26 PM
I ended up using a different pdf library that doesn't have this problem and works perfectly:
Marked as answer by HerrimanCoder on 1/20/2017 at 8:26 AM