Reputation: 4946
I have two questions:
On this old manual I found some useful toc-options like --toc-depth
or --toc-l1-font-size
. It seems they aren't available in latest wkhtmltopdf version - so how can I set toc-depth and toc-font-size now?
I want every of my sub-chapters (toc-level 2) begin on a new page:
Upvotes: 1
Views: 1248
Reputation: 17010
In the current version, you can use a XSLT file to customize quite anything of the style of the generated ToC. Here are relevant quotes from the documentation:
The table of content is generated via XSLT which means that it can be styled to look however you want it to look. To get an aide of how to do this you can dump the default xslt document by supplying the
--dump-default-toc-xsl
, and the outline it works on by supplying--dump-outline
.The XSLT document can be specified using the
--xsl-style-sheet
switch. For example:wkhtmltopdf toc --xsl-style-sheet my.xsl http://qt-project.org/doc/qt-4.8/qstring.html qstring.pdf
The
--dump-default-toc-xsl
switch can be used to dump the default XSLT style sheet to stdout. This is a good start for writing your own style sheet
That's what I did to hide specific levels from the ToC. I edited the XSLT file adding a CSS class to <li>
(line 40 in the default XSLT) and <ul>
(line 55) elements. In that class name I counted the ancestor nodes to get the "level" of depth of the items.
<li class="level-{count(ancestor::*) - 1}">
<ul class="level-{count(ancestor::*) - 1}">
Then I added some CSS rules adding <style>
inside <head>
:
.level-2, .level-3, .level-4 {
display: none;
}
You can place a <div style="page-break-after: always"></div>
in yout HTML before your sub-chapters to force them on a new page.
Upvotes: 5