Free Support Forum - aspose.com

HTML to Word to PDF - Inline Anchor Tags

As per this old thread: HTML to PDF: Treatment of links

We have updated our code to convert HTML to Word before then saving as a PDF to ensure bookmarks are created… however, in page anchor tags just don’ work.

For example:
<a href="#div1">Link</a>
<div id="div1">

The link will render as a hyperlink within both Word and the resulting PDF document, but the links just don’t work.

Is there method for preserving inline anchor tags on conversion?

@jayoffice365,

You need to point link to a bookmarked location. Please see these sample documents (link to bookmark.zip (23.2 KB)) and try running the following code:

Document doc = new Document("D:\\temp\\inp.html");
doc.Save("D:\\temp\\18.11.docx");
doc.Save("D:\\temp\\18.11.pdf");

Thanks, that does work… but this approach does not support HTML5. Is this going to be fixed to that you can simply use the id attribute?

@jayoffice365,

Please ZIP and upload your simplified input HTML file here for testing. We will investigate the issue further on our end and provide you more information.

As requested test.zip (18.5 KB)

@jayoffice365,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-17799. We will further look into the details of this problem and will keep you updated on the status of the linked issue.