PDF Bookmarks and TOC

amardaxini edited this page Jun 8, 2011 · 2 revisions

PDF Bookmark

Pdf book mark can be generated using bookmarks tag.

Basic example is given below or refer here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <bookmarks>
   <bookmark <strong>name="Section 1" href="#section_1"</strong>>
    <bookmark name="Section 1.1" href="#section_11"></bookmark>
    <bookmark name="Section 1.2" href="#section_12"></bookmark>
   </bookmark>
  <bookmark name="Section 2" href="#section_2"></bookmark>
  <bookmark name="Section 2" href="#section_3"></bookmark>
 </bookmarks>
  </head>
<body>
 <div style="page-break-before: always;">
  <a <strong>name="section_1"</strong>>Section 1</a>
 </div>
 <div style="page-break-before: always;">
  <a name="section_11">Section 1.1</a>
 </div>
 <div style="page-break-before: always;">
  <a name="section_12">Section 1.1.2</a>
 </div>
 <div style="page-break-before: always;">
   <a name="section_2">Section 2</a>
 </div>
 <div style="page-break-before: always;">
   <a name="section_3">Section 3</a>
 </div>

</body>
</html>

Table Of Content TOC

Toc can be generated many ways one of the way is using leader.

Basic example is given below.More info regarding leader is available here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>TOC Demo</title>
  <style type="text/css" media="print">
    .toc a::after { content: leader('.') target-counter(attr(href), page); }
    h2, h3, h4 { page-break-before: always; }
  </style>
</head>
<body>
<h1>TOC Demo</h1>
<b>Contents</b>
<ol class="toc">
  <li><a href="#xil_1">Document History</a></li>
  <li><a href="#xil_2">An Introduction to Flying Saucer</a>
    <ol>
      <li><a href="#xil_3">What it is</a></li>
      <li><a href="#xil_4">What it does</a></li>
      <li><a href="#xil_5">What you can do with it</a></li>
      <li><a href="#xil_6">Where the Saucer Does not Fly (what it can't do)</a></li>
      <li><a href="#xil_7">License and Dependencies</a></li>
      <li><a href="#xil_8">Requirements for Running and Using Flying Saucer</a></li>
      <li><a href="#set_classpath">Setting your Classpath</a></li>
      <li><a href="#xil_9">Sample Applications</a>
        <ol>
          <li><a href="#xil_10">The Browser</a></li>
          <li><a href="#xil_11">The About Box</a></li>
          <li><a href="#xil_12">DocBook</a></li>
          <li><a href="#xil_13">SVG</a></li>
        </ol>
      </li>
    </ol>
  </li>
</ol>

<h2 id="xil_1">Document History</h2>
<h2 id="xil_2">An Introduction to Flying Saucer</h2>
<h3 id="xil_3">What it is</h3>
<h3 id="xil_4">What it does</h3>
<h3 id="xil_5">What you can do with it</h3>
<h3 id="xil_6">Where the Saucer Does not Fly (what it can't do)</h3>
<h3 id="xil_7">License and Dependencies</h3>
<h3 id="xil_8">Requirements for Running and Using Flying Saucer</h3>
<h3 id="set_classpath">Setting your Classpath</h3>
<h3 id="xil_9">Sample Applications</h3>
<h4 id="xil_10">The Browser</h4>
<h4 id="xil_11">The About Box</h4>
<h4 id="xil_12">DocBook</h4>
<h4 id="xil_13">SVG</h4>

</body>
</html>