HTML to PDF with relative image file path starting with a slash

Hi, I’m using Aspose PDF to convert HTML doc to PDF. The HTML contains reference to a file on the local hard drive. I have used code samples from the forum and your manuals.


When I start my image URL with a slash, i.e. /UploadedImages/koala.jpg, the PDF converter look in C:\UploadedImages for the image. If the URL doesn’t start with a slash, i.e. UploadedImages/koala.jpg, the HtmlInfo.ImageUrl property is respected and the converter looks for the image in C:\subfolder\UploadedImages. I have verified this behavior using the ProcMon file system monitoring tool.

Unfortunately I cannot control how my image URLs are generated, so do you have any hints on how I proceed to reference my images with a slash prefix?

const string html = @"<img src=""/UploadedImages/koala.jpg"">";
MemoryStream ms = new MemoryStream();
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, htmlString);
text.IsHtmlTagSupported = true;
section.Paragraphs.Add(text);
pdf.HtmlInfo.ImgUrl = “C:/subfolder/”;
pdf.Save(ms);

Hi Lars,


Thanks for your inquiry. After initial investigation we have logged an investigation ticket as PDFNEWNET-37779 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-37779) have been fixed in Aspose.Pdf for .NET 10.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.