I have this HTML:
<table style="width:100%" class="table table-bordered"><tbody><tr><td><p><img src="/User/Images/logo-48_20200612183312_78003.jpg" style="width: 64px;"></p></td><td><p>Development, Systems & Technologies</p><p>Santiago</p></td></tr></tbody></table>
That HTML only includes the text in the generated PDF file, bypassing the image.
This is the code I am using to convert that paragraph:
private IList<IElement> ConvertHtmlToElements(string html)
{
ConverterProperties properties = new ConverterProperties();
properties.SetBaseUri(HttpContext.Current.Server.MapPath("/"));
return HtmlConverter.ConvertToElements(html, properties);
}
I am using iText7 7.1.11 and iText7.pdfhtml 3.0.0.
I should also tell you that this same code works perfectly, with the same image, using iText7 7.1.2 and iText7.pdfhtml 2.0.2.
Something has changed between those versions?
Of couse the image is accesible using https://server/User/Images/logo-48_20200612183312_78003.jpg
Jaime
properties.SetBaseUri
using a physical path that ends in backslash and the IMG SRC attribute starts with a/
, images are not rendered in the PDF. To solve it, I have used this call for the HTML:html = html.Replace("img src=\"/", "img src=\"");
.... I don't really know why if I remove only the last backslash at the end of the physical path, it does not work either. I had to remove the/
to the beginning of the IMG SRC path. Maybe, it is due because this is Window and physical path uses backslash while the IMG SRC uses slash. – jstuardo