Location: PHPKode > projects > Html2ps > html2ps-2.0.43/help/generated_toc.html
<title>Generated Content: Table of Contents</title>
<link rel="stylesheet" type="text/css" medial="all" title="Default" href="css/help.css"/>
<h1>Generated Content: Table of Contents</h1>
<h2>Features and limitations</h2>
<p>The TOC is generated using H1-H9 tags from the original document; you don't need to 
do anything specific with these tags, they're included automatically. If you've enabled 
hyperlinks rendering, TOC items will be clickable, pointing to the appropriate pages.<p>
<p>TOC may be placed at the beginning or at the end of the document on separate page or 
it may be inserted at the appropriate place <strong>in</strong> the document. In the latter 
case you should insert the following code in the document:
&lt;div id="html2ps-toc"&gt;&lt;/div&gt;
If this DIV is not empty, TOC will be rendered after content (it is not replaced).
<p>Note that TOC feature will <strong>not</strong> work in batch mode from the same reasons
page numbering doesn't. In batch mode TOC will be generated for <strong>each</strong> document 
in batch.</p>

<h2>How can I control TOC appearance?</h2>
<p>TOC appearance may be controlled by following CSS selectors:</p>
<td>Applies to the TOC as a whole</td>
<td>Applies to every TOC item</td>
<td>Applies to TOC item of the given level of nesting</td>
<td>Applies to the textual TOC item name</td>
<td>Applies to the textual TOC item name on the Lth level of nesting</td>
<td>Applies to TOC page number</td>
<td>Applies to TOC page number on the Lth level of nesting</td>
<td>Applies to Xth TOC item as a whole</td>
<td>Applies to Xth TOC item name</td>
<td>Applies to Xth TOC item page number</td>
<p>Note that every TOC item may be represented by a following code:<p>
&lt;div id="html2ps-toc-X" class="html2ps-toc-wrapper html2ps-toc-L-wrapper"&gt;
&lt;div id="html2ps-toc-name-X" class="html2ps-toc-name html2ps-toc-L-name"&gt;NAME&lt;/div&gt;
&lt;div id="html2ps-toc-page-X" class="html2ps-toc-page html2ps-toc-L-page"&gt;PAGE NUMBER&lt;/div&gt;

<h2>How can I generate TOC using the webinterface?</h2>
<p>Provide 'toc' parameter (set the "Table of contents" flag) and choose one of 'after', 'before' or 'placeholder' values for 'toc-location' parameter
(select appropriate value from "Place TOC at" pull-down).</p>

<h2>How can I generate TOC using API?</h2>
Use the following PHP code:
$pipeline->add_feature('toc', array('location' => $location_code);
where $location_code should contains one of the 'after', 'before' or 'placeholder' values. 

<h2>How can I override the default TOC generator behaviour?</h2>
<p>You may override the following:</p>
<li>items being selected as TOC items;</li>
<li>how document is being modified (the place TOC is added to);</li>
<p>First of all, access the feature object:
$toc_feature =& FeatureFactory::get('toc');
(note that it is bad-bad-bad idea to create feature objects by yourself; 
use FeatureFactory factory class instead).</P>
After this, you may use 'set_anchor_locator' and 'set_document_updater' to override 
these behaviours. Both methods accepts single parameter: an behaviour (strategy) object.
It should implement one 'run' method taking $toc_box (preparent document element for the TOC), 
$media and $document as parameters. Anchor locating strategy object should return an array, 
every element of which is an associative array containing the following items:
<li>'name' &mdash; TOC item text</li>
<li>'level' &mdash; nesting level</li>
<li>'anchor' &mdash; ID of the target element</li>
<li>'element' &mdash; target element itself</li>
Document updater strategy object does not need to return anything.
For sample code refer to features/toc.php file.

Return current item: Html2ps