3

I'm using wkhtmltopdf to create an user manual from an html source. I already managed to number the pages thanks to this.

Now I wonder if there is any way to auto generate a document index based on the header tags on the html source.

For instance, if I have this:

<h1>Cars</h1>                   (page 3)
   <p>blah blah blah</p>
   <h2>Peugeot</h2>             (page 3)
      <p>blah blah blah</p>
   <h2>Renault</h2>             (page 4)
      <p>blah blah blah</p>
<h1>Supermarkets</h1>           (page 5)
   <p>blah blah blah</p>
   <h2>Walmart</h2>             (page 7)
      <p>blah blah blah</p>
   <h2>Carrefour</h2>           (page 11)
      <p>blah blah blah</p>

I would like to have an auto-generated document index that looks like this:

User Manual Index

Cars.......................3
  Peugeot..................3
  Renault..................4
Supermarkets...............5
  Walmart..................7
  Carrefour................11

Is it possible to achieve it using wkhtmltopdf / JavaScript ? At least could you please advice me where to start?

Thanks in advance.

Community
  • 1
  • 1
Fracu
  • 835
  • 1
  • 13
  • 28
  • 1
    I would take a look at the table of contents options available to wkhtmltopdf via http://wkhtmltopdf.org/usage/wkhtmltopdf.txt toc options. – DMH Sep 05 '16 at 09:17

0 Answers0