HTML2PDF Table of Contents questions


There are few areas which are troubling us:

  1. How to change the font (font name, font size) of “Table Of Content” ?

  2. Can we start “Table Of Content” from 2nd page ?

  3. How to remove “Table Of Content” Link ?

Note : TOCSettings.SetCaptionText(“”);, changes both highlighted text as well as the heading (Table Of Content text)., but we need to keep heading and need to remove the highlighted text.

  1. Is there any way to find out the number of pages “Table of Content” is occupied ?

  2. Can we update the destination of a bookmark ?

Basically we need to update the top value of the destination, so that it will navigate few point up from the actual bookmark location.

  1. Could you provide us example of TOCSettings.SetXSL().


  1. HTML2PDF::TOCSettings::SetXsl method. Below is the default xsl used. Simply modify it and pass it into the function.

  2. The table of contents starts from wherever you inject it using HTML2PDF::InsertTOC method. You could always use other PDFNet methods, such as PDFDoc.PagePushFront() to make further changes.

  3. To completely remove the Table of Content bookmark, both from the PDF and the what you see in the table of contents, change the toc.xsl file passing into HTML2PDF::TOCSettings::SetXsl, so that

    Table of Content

    is something other than a heading. For example.

Table of Content

  1. If you use the Bookmarks API, and find the first page of the first bookmark (assuming you took Table of Contents completely out of the bookmarks), then this would tell you the first page after the table of contents.

  2. Sure, using the Bookmarks API of PDFNet. See the BookmarksTest sample.

  3. Here you go…


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version=“1.0”




<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"


indent=“yes” />

<xsl:template match=“outline:outline”>

Table of Content h1 { text-align: center; font-size: 20px; font-family: arial; } div {border-bottom: 1px dashed rgb(200,200,200);} span {float: right;} li {list-style: none;} ul { font-size: 20px; font-family: arial; } ul ul {font-size: 80%; } ul {padding-left: 0em;} ul ul {padding-left: 1em;} a {text-decoration:none; color: black;}

Table of Content


    <xsl:template match=“outline:item”>

  • <xsl:if test="@title!=’’">

    <xsl:if test="@link">

    <xsl:attribute name=“href”><xsl:value-of select="@link"/></xsl:attribute>


    <xsl:if test="@backLink">

    <xsl:attribute name=“name”><xsl:value-of select="@backLink"/></xsl:attribute>


    <xsl:value-of select="@title" />

    <xsl:value-of select="@page" />


      <xsl:apply-templates select=“outline:item”/>

  • </xsl:template>