如何从WKHTMLTOPDF中的目录中删除目录? [英] How to remove the Table of Contents from the Table of Contents in WKHTMLTOPDF?

查看:269
本文介绍了如何从WKHTMLTOPDF中的目录中删除目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

您可以使用XSL样式表完全控制TOC的生成.通过将参数--dump-default-toc-xsl赋予wkhtmltopdf,可以获得默认的样式表.

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.

检查时,您对<body><h1>...</h1> H1元素和测试xsl:if test="(@title!='')"

When you examine it, you are particularly interested in the <body><h1>...</h1> H1 element and the test xsl:if test="(@title!='')"

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

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

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

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.

这篇关于如何从WKHTMLTOPDF中的目录中删除目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆