Table of contents

PD4ML allows to insert into the generated PDFs a table of contents (TOC) built from <H1> – <H6> headings hierarchy.

There is a special tag <pd4ml:toc> intended for that. TOC can be inserted into any document position. Only one TOC object is allowed. <pd4ml:toc> tag is ignored in multi-source PDF generation scenarios (when an array of URLs is passed to be converted to PDF).

<pd4ml:toc> can be parameterized with pncorr attribute. The numeric value given in the attribute allows to correct page numbers in the TOC. The pncorr value will be added to TOC’s page numbers.

Internally the TOC table is represented with an HTML table like below:

<table class="ptoc-table" cellspacing="0">
<td class="ptoc-left-col"><a class="ptoc-link" href="#ptoc_1">
<div class="ptoc1-style-left">Chapter 1<pd4ml-dots></div></a></td>
<td class="ptoc-right-col"><a class="ptoc-link" href="#ptoc_1">
<div class="ptoc1-style-right">1</div></a></td></tr>
<td class="ptoc-left-col"><a class="ptoc-link" href="#ptoc_2">
<div class="ptoc2-style-left">Chapter 1.1<pd4ml-dots></div></a></td>
<td class="ptoc-right-col"><a class="ptoc-link" href="#ptoc_2">
<div class="ptoc2-style-right">2</div></a></td></tr>
<td class="ptoc-left-col"><a class="ptoc-link" href="#ptoc_3">
<div class="ptoc2-style-left">Chapter 1.2<pd4ml-dots></div></a></td>
<td class="ptoc-right-col"><a class="ptoc-link" href="#ptoc_3">
<div class="ptoc2-style-right">2</div></a></td></tr>
<td class="ptoc-left-col"><a class="ptoc-link" href="#ptoc_4">
<div class="ptoc3-style-left">Chapter 1.2.1<pd4ml-dots></div></a></td>
<td class="ptoc-right-col"><a class="ptoc-link" href="#ptoc_4">
<div class="ptoc3-style-right">3</div></a></td></tr>

The following style sheet is applied to TOC by default and can be overriden:

.ptoc1-style-left { margin-left: 0 }
.ptoc2-style-left { margin-left: 16 }
.ptoc3-style-left { margin-left: 32 }
.ptoc4-style-left { margin-left: 48 }
.ptoc5-style-left { margin-left: 64 }
.ptoc6-style-left { margin-left: 80 }
.ptoc-table { border: 0; width: 100% }
.ptoc-left-col { width: 99%; padding-right: 0 }
.ptoc-right-col { text-align: right; padding-left: 0; vertical-align: bottom }
.ptoc-link { text-decoration: none; color: black }