使用wkhtmltopdf时如何设置内容表的位置

4 pdf-generation wkhtmltopdf

我正在使用wkhtmltopdf从html页面生成pdf.

我的问题是如何设置位置内容表页?它似乎是在第一页开头自动生成的.另外,如何设置内容的CSS内容?

Mar*_*rer 6

--xsl-style-sheet (file)wkhtmltopdf 有一个参数,因此在扩展命令行--help(或-H)中详细说明.

A table of content can be added to the document by adding a toc object to
the command line. For example:  

  wkhtmltopdf toc http://doc.trolltech.com/4.6/qstring.html qstring.pdf

The table of content is generated based on the H tags in the input
documents. First a XML document is generated, then it is converted to
HTML using XSLT.

The generated XML document can be viewed by dumping it to a file using
the --dump-outline switch. For example:

  wkhtmltopdf --dump-outline toc.xml http://doc.trolltech.com/4.6/qstring.html qstring.pdf

The XSLT document can be specified using the --xsl-style-sheet switch.
For example:

  wkhtmltopdf toc --xsl-style-sheet my.xsl http://doc.trolltech.com/4.6/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

  wkhtmltopdf --dump-default-toc-xsl

The XML document is in the namespace 
  http://code.google.com/p/wkhtmltopdf/outline

it has a root node called "outline" which contains a number of
"item" nodes. An item can contain any number of item. These are the
outline subsections to the section the item represents. A item node
has the following attributes:

 - "title" the name of the section
 - "page" the page number the section occurs on
 - "link" a URL that links to the section.
 - "backLink" the name of the anchor the the section will link back to.

The remaining TOC options only affect the default style sheet
so they will not work when specifying a custom style sheet.

因此,您可能会根据其默认值定义自己的XSLT,并将其传入.没有问题.