I am generating a pdf using WKHTMLTOPDF with the table of content option, but it is adding itself to the table of contents, showing that it is on page 2.
Thoughts on removing this?
You have full control over the TOC generation using XSL stylesheets for their generation. You can get the default stylesheet used by giving the argument --dump-default-toc-xsl
to wkhtmltopdf.
When you examine it, you are particularly interested in the <body><h1>...</h1>
H1 element and the test xsl:if test="(@title!='')"
For example, when I want to remove the TOC self-reference from itself, this is the relevant part of my stylesheet:
stuff above
<h1>My little TOC</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!='') and (@title!='My little TOC')">
stuff below
When you save the new TOC XSL, you then need to reference it in your wkhtmltopdf arguments using something like --page-size A4 toc --xsl-style-sheet test.xsl TempFile.html TempFile.pdf
.
来源:https://stackoverflow.com/questions/10403721/how-to-remove-the-table-of-contents-from-the-table-of-contents-in-wkhtmltopdf