HTML2PDF Table of Contents questions

515 views
Skip to first unread message

Ryan

unread,
Nov 21, 2013, 12:46:04 PM11/21/13
to pdfne...@googlegroups.com
Q)

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(“<string>”);, 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.

 

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

5.       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.

6.       Could you provide us example of TOCSettings.SetXSL().
------------------------------------------------------------------------------------
A)
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 <h1>Table of Content</h1> is something other than a heading. For example.

<div style="text-align:center;font-size:20px;font-family:arial;border-bottom-style:none;">Table of Content</div><br/>

4. 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.

5. Sure, using the Bookmarks API of PDFNet. See the BookmarksTest sample.  http://www.pdftron.com/pdfnet/samplecode/BookmarkTest.cs

6. Here you go...

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

<xsl:stylesheet version="1.0"

               
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

               
xmlns:outline="http://code.google.com/p/wkhtmltopdf/outline"

               
xmlns="http://www.w3.org/1999/xhtml">

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

             
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

             
indent="yes" />

 
<xsl:template match="outline:outline">

   
<html>

     
<head>

       
<title>Table of Content</title>

       
<style>

          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;}

       
</style>

     
</head>

     
<body>

       
<h1>Table of Content</h1>

       
<ul><xsl:apply-templates select="outline:item/outline:item"/></ul>

     
</body>

   
</html>

 
</xsl:template>

 
<xsl:template match="outline:item">

   
<li>

     
<xsl:if test="@title!=''">

       
<div>

         
<a>

           
<xsl:if test="@link">

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

           
</xsl:if>

           
<xsl:if test="@backLink">

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

           
</xsl:if>

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

         
</a>

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

       
</div>

     
</xsl:if>

     
<ul>

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

     
</ul>

   
</li>

 
</xsl:template>

</xsl:stylesheet>



Reply all
Reply to author
Forward
0 new messages