-
Notifications
You must be signed in to change notification settings - Fork 127
Hyperlinks
Only absolute or relative Uri are processed. Javascript link are ignored.
These URI are valid
- ://www.site.com
- www.site.com
- http://www.site.com
Anchors are supported and you can turn off this option (enabled by default).
Anchoring is link to a section within the document.
converter.SupportsAnchorLinks = false;There is a predefined anchor inside Word that refers to the top of the document : #_top. This anchor is always respected despite the status of SupportsAnchorLinks.
For user convenience, we also support the anchor #top as an alias.
If the top anchor is missing in the Word document, it will be automatically created in the 1st paragraph of the body.
<h1>Table of Contents</h1>
<ul>
<li><a href="#anchor1">Heading 1</a></li>
<li><a href="#anchor2">Heading 2</a></li>
</ul>
<h1 id="anchor1">Heading 1</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dictum leo quis ipsum tempor nec ultrices sapien elementum.
<h1 id="anchor2">Heading 2</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dictum leo quis ipsum tempor nec ultrices sapien elementum.
<div style="text-align: right">
<li><a href="#_top">Back to ToC</a></li>
</div>
Image can be clickable and redirecting to a link or anchor.
<a href="https://github.com/onizet/html2openxml">HtmlToOpenXml</a>
<br><br>
<a href="http://www.wikipedia.org">
<img alt="Wikipedia, the Free Encyclopedia" src="wikipedia.png" />
</a>
Bookmarks are section in the OpenXml document that you can link to (things like Table of Content for instance). When the parser meet internal anchors, it will use bookmarks behind the scene.
If for any reason you want to register a bookmark for a specific content (like Heading), you can define the bookmark with this attribute: data-bookmark.
<h1 data-bookmark="anchor1">Heading 1.1</h1>