7

我正在使用带有目录选项的 WKHTMLTOPDF 生成 pdf,但它正在将自身添加到目录中,表明它在第 2 页上。

想去掉这个?

4

1 回答 1

13

您可以使用 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

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

于 2012-07-12T07:37:23.977 回答