Home
|
Contact
HOME
HTML to PDF
PDF TOOLS
DEMO
DOWNLOAD
BUY NOW
SUPPORT
HTML to PDF Library for .NET
EvoPdf Chromium for .NET
Cross-Platform
HTML to PDF for .NET
HTML to PDF for Java
HTML to PDF for Azure
HTML to PDF for UWP
HTML to PDF for Xamarin
HTML to PDF for Mono
HTML to PDF Converter
EvoPdf Chromium
HTML to Image Converter
HTML to SVG Converter
SVG to PDF Converter
Word to PDF Converter
Excel to PDF Converter
RTF to PDF Converter
PDF to Text Converter
PDF to Image Converter
PDF to HTML Converter
PDF Images Extractor
PDF Print
PDF Merge
PDF Split
PDF Security
PDF Viewer for ASP.NET
PDF Viewer for WinForms
Cross-Platform
PDF Library for .NET
HTML to PDF Converter Demo
EvoPdf Chromium Demo
Order Online
Licensing & Prices
License Renewal
License Agreement
Our Customers
HTML to PDF Converter User Guide
EvoPdf Chromium User Guide
Contact Support
Collapse
Expand
HTML to PDF Converter
Getting Started with HTML to PDF
HTML Content Destination and Scaling in PDF
Convert the Current HTML Page to PDF
Convert a HTML Page to PDF in Same Session
Merge Multiple HTML Pages into a Single PDF
Merge HTML with Existing PDF Documents
Partially Convert of a HTML Page to PDF
Repeat HTML Table Header and Footer in PDF
Headers and Footers
Page Breaks Control
Screen and Print Media Types
Conversion Triggering Modes
Hierachical Bookmarks
Table of Contents
Auto Create a Table of Contents
Define in HTML the Table of Contents Items
Table of Contents for Multiple HTMLs
Insert PDF Before Table of Contents
Live PDF Forms
HTML5 Features
HTTP GET and POST, Proxy Options
HTTP Headers and Cookies
Fonts Embedding
HTML Elements Location in PDF
HTML Elements Visibility in PDF
URI Links in PDF
Internal Links in PDF
File Links and Attachments
Text Notes in PDF
PDF Actions
HTML to PDF Elements
HTML to Image Elements
Images Quality in Generated PDF
Flash and Extensions Support
Watermarks and Stamps
PDF Background and Foreground
PDF/A and PDF/X Standards
CMYK and GrayScale Color Spaces
PDF Viewer Preferences
PDF Security Features
HTML to Image Converter
PDF Creator
PDF Editor
Live Demo
Description
Sample Code
Define in HTML the Table of Contents Items
EVO HTML to PDF Converter allows you to define a table of contents directly in HTML using a set of special attributes. You can set the attribute 'data-toc-item' on a HTML element to enable the creation a table of contents entry for that element in PDF. Additionally you can specify the item level in table of contents with 'data-toc-level' attribute and the bookmark title with 'data-toc-title' attribute. The Full Description and a Code Sample can be accessed from the top tabs.
Convert HTML with Table of Contents
Convert URL or Local File
HTML String with Table of Contents
<!DOCTYPE html> <html> <head> <title>Define a Table of Contents in HTML</title> <style type="text/css"> body { font-family: 'Times New Roman'; font-size: 14px; } .level1_toc { font-weight: bold; font-size: 24px; } .level2_toc { font-weight: bold; font-size: 20px; page-break-before: always; } .level3_toc { font-weight: bold; font-size: 16px; } .level4_toc { font-weight: bold; font-size: 14px; } </style> </head> <body> <span data-toc-item="true" data-toc-level="1" data-toc-title="Part 1 of Table of Contents" class="level1_toc">Part 1 of a Table of Contents Defined in HTML</span><br /> <br /> Any HTML element can be marked to become an item in the table of contents in the generated PDF document using the <b><i>data-toc-item="true"</i></b> attribute. Additionally you can define the table of contents item level using the <b><i>data-toc-level</i></b> attribute and the table of contents item title using the <b><i>data-toc-title</i></b> attribute.<br /> <br /> <br /> <span style="font-size: 20px; font-weight: bold">Part Chapters:</span><br /> <div style="margin-left: 20px"> <br /> <a href="#part1_chapter1" style="font-size: 16px; font-weight: bold; line-height: 30px">Chapter 1</a><br /> <a href="#part1_chapter2" style="font-size: 16px; font-weight: bold; line-height: 30px">Chapter 2</a><br /> </div> <br /> <br /> <span data-toc-item="true" data-toc-level="2" id="part1_chapter1" class="level2_toc">1.1 Chapter 1 of Part 1</span><br /> <br /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">1.1.1 Section 1 of Chapter 1 of Part 1</span><br /> <br /> Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">1.1.2 Section 2 of Chapter 1 of Part 1</span><br /> <br /> Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">1.1.3 Section 3 of Chapter 1 of Part 1</span><br /> <br /> Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. <br /> <br /> <span data-toc-item="true" data-toc-level="2" id="part1_chapter2" class="level2_toc">1.2 Chapter 2 of Part 1</span><br /> <br /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">1.2.1 Section 1 of Chapter 2 of Part 1</span><br /> <br /> Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. <br /> <br /> <span data-toc-item="true" data-toc-level="4" class="level4_toc">1.2.1.1 Paragraph 1 of Section 1 of Chapter 2 of Part 1</span><br /> <br /> Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. <br /> <br /> <span data-toc-item="true" data-toc-level="4" class="level4_toc">1.2.1.2 Paragraph 2 of Section 1 of Chapter 2 of Part 1</span><br /> <br /> Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">1.2.2 Section 2 of Chapter 2 of Part 1</span><br /> <br /> Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. <br /> <br /> <!-- Part 2 --> <span data-toc-item="true" data-toc-level="1" data-toc-title="Part 2 of Table of Contents" style="page-break-before: always" class="level1_toc">Part 2 of a Table of Contents Defined in HTML</span><br /> <br /> Any HTML element can be marked to become an item in the table of contents in the generated PDF document using the <b><i>data-toc-item="true"</i></b> attribute. Additionally you can define the table of contents item level using the <b><i>data-toc-level</i></b> attribute and the table of contents item title using the <b><i>data-toc-title</i></b> attribute.<br /> <br /> <br /> <span style="font-size: 20px; font-weight: bold">Chapters:</span><br /> <div style="margin-left: 20px"> <br /> <a href="#part2_chapter1" style="font-size: 16px; font-weight: bold; line-height: 30px">Chapter 1</a><br /> <a href="#part2_chapter2" style="font-size: 16px; font-weight: bold; line-height: 30px">Chapter 2</a><br /> </div> <br /> <br /> <span data-toc-item="true" data-toc-level="2" id="part2_chapter1" class="level2_toc">2.1 Chapter 1 of Part 2</span><br /> <br /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">2.1.1 Section 1 of Chapter 1 of Part 2</span><br /> <br /> Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">2.1.2 Section 2 of Chapter 1 of Part 2</span><br /> <br /> Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">2.1.3 Section 3 of Chapter 1 of Part 2</span><br /> <br /> Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. <br /> <br /> <span data-toc-item="true" data-toc-level="2" id="part2_chapter2" class="level2_toc">2.2 Chapter 2 of Part 2</span><br /> <br /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">2.2.1 Section 1 of Chapter 2 of Part 2</span><br /> <br /> Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. <br /> <br /> <span data-toc-item="true" data-toc-level="3" class="level3_toc">2.2.2 Section 2 of Chapter 2 of Part 2</span><br /> <br /> Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. </body> </html>
Base URL