title: Can the TOC be shown inline with the rest of the PDF?
body: <p>When using the <code>toc</code> option for creating a table of contents using wkhtmltopdf, is it possible to display it inline with the rest of the document? Currently, I can only get it to display as its own page(s) with no other content on it but I would like for it to be immediately followed by the start of my document. I am using the <code>--xsl-style-sheet</code> command to style the toc and I have not seen anything in there that would indicate this is possible.</p>
  
  <p>Just to visualize it, here is what I have now:</p>
  
  <pre><code>1. Title ........ 1
  2. Title 2 ...... 4
  3. Title 3 ...... 5
  
  
  
  
  
  
  
  
  
  -------------------------
  
  1. Title
  </code></pre>
  
  <p>where "------" denotes a page break. And what I am after is this:</p>
  
  <pre><code>1. Title ........ 1
  2. Title 2 ...... 4
  3. Title 3 ...... 5
  
  
  1. Title
  </code></pre>
  
  <p>The command being used to generate this:</p>
  
  <pre><code>./wkhtmltopdf 
      --footer-center '- [page] -' 
      --enable-javascript 
      --margin-top 40 
      --margin-bottom 20 
      --footer-spacing 10 
      --page-size Letter 
      --orientation portrait 
      --header-spacing 10 
      --header-html ./1398708303-header.html 
      cover ./1398708303-cover.html 
      toc 
          --xsl-style-sheet ./templates/pages/pdf/toc-style.xsl 
      ./1398708303-content.html 
      ./1398708303.pdf
  </code></pre>
  
  <p>I obscured URLs, obviously. I cannot provide the files being used to generate the HTML due to an NDA and confidentiality agreement, but even a simple HTML file that is just a list of various headers generates as described above.</p>
  
  <p>I am current running the Debian dev builds from <a href="http://wkhtmltopdf.org/downloads.html" rel="nofollow">http://wkhtmltopdf.org/downloads.html</a>. I have also tried the stable builds as well as various other releases such as builds from h4cc and pilotftzi. The official releases are the only ones who seem to provide proper toc support at all.</p>
  
  <p>'--xsl-style-sheet' content:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:outline="http://wkhtmltopdf.org/outline"
                  xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;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" /&gt;
      &lt;xsl:template match="outline:outline"&gt;
          &lt;html&gt;
              &lt;head&gt;
                  &lt;title&gt;Table of Contents&lt;/title&gt;
                  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
                  &lt;style type="text/css"&gt;
                      #header, #header h1 {
                          text-align:left;
                          font-size:24px;
                          font-weight: bold;
                          font-family:arial;
                          margin-bottom: 5px;
                      }
  
                      #header {
                          display: inline;
                      }
  
                      #header h1 {
                          display: inline;
                      }
  
                      ol li {
                          font-size: 16px;
                          font-weight: normal;
                      }
  
                      ol {
                          max-width: 100%;
                          overflow-x: hidden;
                          list-style: upper-roman;
                      }
  
                      ol li ol {
                          list-style: upper-alpha;
                      }
  
  
                      .title {
                          background: #fff;
                          padding-right: 5px;
                      }
  
                      .page {
                          background: #fff;
                          padding: 0 0 0 5px;
                          position: absolute;
                          right: 0;
                      }
  
                      li:before {
                          float: left;
                          width: 0;
                          white-space: nowrap;
                          content:
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                              ". . . . . . . . . . . . . . . . . . . . "
                      }
  
                      li, ol {
                          padding-top: 0 !important;
                          padding-bottom: 0 !important;
                          margin-top: 0 !important;
                          margin-bottom: 0 !important;
                      }
  
                      ol &gt; li &gt; ol {
                          padding-left: 20px !important;
                      }
  
                      a {
                          color: #000;
                          text-decoration: none;
                      }
                  &lt;/style&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;div id="header"&gt;I. &lt;h1&gt;Table of Contents&lt;/h1&gt;&lt;/div&gt;
                  &lt;div class="table-of-contents-container"&gt;
                      &lt;ol&gt;&lt;xsl:apply-templates select="outline:item/outline:item"/&gt;&lt;/ol&gt;
                  &lt;/div&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="outline:item"&gt;
          &lt;li&gt;
              &lt;xsl:if test="@title!=''"&gt;
                  &lt;span class="title"&gt;
                      &lt;a&gt;
                          &lt;xsl:if test="@link"&gt;
                              &lt;xsl:attribute name="href"&gt;&lt;xsl:value-of select="@link"/&gt;&lt;/xsl:attribute&gt;
                          &lt;/xsl:if&gt;
                          &lt;xsl:if test="@backLink"&gt;
                              &lt;xsl:attribute name="name"&gt;&lt;xsl:value-of select="@backLink"/&gt;&lt;/xsl:attribute&gt;
                          &lt;/xsl:if&gt;
                          &lt;xsl:value-of select="@title" /&gt;
                      &lt;/a&gt;
                  &lt;/span&gt;
                  &lt;span class="page"&gt;&lt;xsl:value-of select="@page" /&gt; &lt;/span&gt;
              &lt;/xsl:if&gt;
              &lt;ol&gt;
                  &lt;xsl:comment&gt;added to prevent self-closing tags in QtXmlPatterns&lt;/xsl:comment&gt;
                  &lt;xsl:apply-templates select="outline:item"/&gt;
              &lt;/ol&gt;
          &lt;/li&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>