如何在wkhtmltopdf输出中更改TOC位置?

问题描述 投票:3回答:1

我需要TOC在第3页。显然,如果有办法控制它,它必须通过XSL样式表。我所有的搜索尝试都没有给我一个线索。有可能吗?

我不能使用cover选项,因为我需要在第一页和第二页显示标题。

xslt pdf pdf-generation wkhtmltopdf
1个回答
2
投票

好的我已经找到了使用wkhtmltopdf 0.11的方法。我已经将前两页提取到一个单独的HTML文档中,然后像这样运行它

wkhtmltopdf [options] page cover.html toc --xsl-style-sheet ... input_file.html out.pdf

不幸的是,它花了比我预期的更多的努力,因为我通过wicked_pdf在Rails应用程序中使用它,并且它对新的选项格式不好用,所以我不得不分叉并进行必要的更改。

wicked_pdf生成的命令行如下所示(省略了长路径):

"c:/program files (x86)/wkhtmltopdf/wkhtmltopdf.exe"  
   --header-html "file:///path/to/header" --footer-html "file:///path/to/footer" 
   --margin-top 20 --margin-bottom 15 --margin-left 5 --margin-right 40    page "file:///path/to/cover/page" --disable-javascript  toc --xsl-style-sheet "path/to/style/sheet"  - -
© www.soinside.com 2019 - 2024. All rights reserved.