Skip to content

Hyperlinks

Olivier Nizet edited this page Sep 24, 2024 · 3 revisions

External Links

Only absolute or relative Uri are processed. Javascript link are ignored.

These URI are valid

Anchors

Anchors are supported and you can turn off this option (enabled by default). Anchoring are link to a section within the document.

converter.ExcludeLinkAnchor = true;

Anchoring top of the document

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 ExcludeLinkAnchor. 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>

internal anchors

Embed an image inside an anchor

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>

image with link