Free Support Forum - aspose.com

Converting html to pdf, links on images are not working (Aspose.PDF for .NET)

Hello support team,

Converting html to pdf. The html document contains images with links. In the result pdf links on images are gone.

Links on images <a href="…"><img src="…" /></a> are not working.
Links on text <a href="…">Link title</a> are working.

The input (there are html file in zip package):
Input document.zip (313 Bytes)

The result:
Output document.pdf (277.6 KB)

The conversion code:

MemoryStream resultStream = new MemoryStream();
using (MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
{
    HtmlLoadOptions options = new HtmlLoadOptions();
    if (contentWidth != null)
    {
        options.PageInfo.Width = contentWidth.Value;
    }
    
    options.IsRenderToSinglePage = true;
    options.IsEmbedFonts = true;
    options.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);

    Document pdfDocument = new Document(htmlStream, options);               
    pdfDocument.Save(resultStream);
}
return resultStream;

Using the latest Aspose.PDF for .NET (21.4.0.0).

Thank you!
Martin

@martin27

I have been able to reproduce the issue on our end. A ticket with ID PDFNET-50067 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.