0

Having an issue with producing a PDF with an image in IText.

We're able to produce the text of the document using IText, but it is not pulling through the image.

We are following the text in their Ebook at https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-converting-html-to-pdf-with-pdfhtml/chapter-1-hello-html-to-pdf

The code in question is below:

void createPdf(string baseUri, string html, string dest)
{
ConverterProperties properties = new ConverterProperties();
properties.SetBaseUri(baseUri);
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create), properties);
}

And as far as we can see the issue is around the string baseUri

We have assumed that this is the directory where the image is held in our C# project in visual studio and have so far used the following to no avail as a string:

  1. /Images/
  2. /Images/NewLogo.png
  3. http://localhost:64070/Images/NewLogo.png

None of these have produced the image in the PDF and any help or suggestions would be greatly appreciated.

Zoe
  • 27,060
  • 21
  • 118
  • 148
badgerless
  • 45
  • 8
  • Thank you for your reply.Would you be able to be more specific though by parent folder/? – badgerless Feb 11 '22 at 16:30
  • We have created a folder under our solution called Images, which is where we have stored the image to be used. – badgerless Feb 11 '22 at 16:39
  • 1
    The following may be helpful: https://stackoverflow.com/questions/69210758/itext7-htmlconverter-does-not-display-gif/69212530#69212530 – Tu deschizi eu inchid Feb 11 '22 at 17:29
  • 1
    Edits that remove fluff [are fine](https://meta.stackoverflow.com/questions/260776/should-i-remove-fluff-when-editing-questions); this particular edit also improves the title (the capitalization doesn't make sense, and tags don't go in the title). Please refrain from further rollbacks – Zoe Feb 14 '22 at 10:51
  • The problem is the user removed IText, where this particular issue is related to IText – badgerless Feb 14 '22 at 13:36
  • Hi, you attached a boilerplate method declaration but how does one reproduce your issue? Can you be more specific in providing details on how to reproduce it and attach the minimal yet reproducible code sample and accompanying resources? Also, have you checked the logs? What does iText say in the logs about retrieving your image? – Alexey Subach Feb 16 '22 at 20:22

1 Answers1

1

We have found that if we set the BaseUri to the location of an image on a url that we are able to produce a Image on a PDF

badgerless
  • 45
  • 8