Click or drag to resize

Internal Links in PDF

The converter turns the HTML links that point to an anchor in the same document into internal links in the PDF: clicking one in a PDF viewer jumps to the place the anchor was rendered, on whatever page that is. This makes it easy to give the generated document a table of contents.

An internal link consists of two HTML elements: the link, written as <a href="#target">Internal Link</a>, and its target, an element whose id is the anchor name, such as <h2 id="target">Link Target</h2>, or a named anchor, <a name="target">Link Target</a>. When the converter finds this construction it creates an internal link in the PDF from "Internal Link" to "Link Target".

Internal links are created by default. Set InternalLinksEnabled to false to leave them out:

PdfConverter pdfConverter = new PdfConverter();
pdfConverter.PdfDocumentOptions.InternalLinksEnabled = false;
pdfConverter.SavePdfFromUrlToFile("https://www.example.com/manual", "manual.pdf");

The Chromium engine resolves every anchor against the document it renders, so internal links work the same way for a URL, an HTML file and an HTML string. When you convert an HTML string, pass the urlBase parameter so that the images, style sheets and other links of the string resolve as well. The conversion methods that take an internalLinksDocUrl parameter accept it for compatibility; the value is not needed.

To have the converter build a table of contents from the headings of the page, with page numbers, use TableOfContentsOptions. The same option on the HTML elements of a Document is InternalLinksEnabled.

See Also