如何从WKHTMLTOPDF中的目录中删除目录?

Ada*_*m D 6 pdf tableofcontents wkhtmltopdf

我正在使用带有内容表选项的WKHTMLTOPDF生成pdf,但它将自己添加到目录中,显示它在第2页.

关于删除这个的想法?

Nen*_*lep 12

您可以使用XSL样式表完全控制TOC生成.您可以通过将参数提供--dump-default-toc-xsl给wkhtmltopdf 来获取使用的默认样式表.

当你检查它时,你对<body><h1>...</h1>H1元素和测试特别感兴趣xsl:if test="(@title!='')"

例如,当我想从自身中删除TOC自引用时,这是我的样式表的相关部分:

            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
Run Code Online (Sandbox Code Playgroud)

当您保存新的TOC XSL时,您需要使用类似的东西在wkhtmltopdf参数中引用它--page-size A4 toc --xsl-style-sheet test.xsl TempFile.html TempFile.pdf.