How to remove the Table of Contents from the Table of Contents in WKHTMLTOPDF?

大憨熊 提交于 2019-12-03 14:45:12

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!