【问题标题】:Snappy & wkhtmltopdf : page numbering in footerSnappy & wkhtmltopdf : 页脚中的页码
【发布时间】:2014-03-04 13:38:50
【问题描述】:

我想在使用 Snappy 和 Wkhtmltopdf 生成的每个页面的页脚中添加页码,但我没有找到任何线索。

我可以设置页脚文本(带有选项'footer-center')但是如何放置页码?

【问题讨论】:

    标签: php pdf wrapper wkhtmltopdf snappy


    【解决方案1】:

    将此添加为接受的答案只是一个 404 链接。

    根据the documentation,Wkhtmltopdf 为我们提供了许多控制页脚文本放置位置的选项:

      --footer-center <text>          Centered footer text
      --footer-font-name <name>       Set footer font name (default Arial)
      --footer-font-size <size>       Set footer font size (default 12)
      --footer-html <url>             Adds a html footer
      --footer-left <text>            Left aligned footer text
      --footer-line                   Display line above the footer
      --no-footer-line                Do not display line above the footer
                                      (default)
      --footer-right <text>           Right aligned footer text
      --footer-spacing <real>         Spacing between footer and content in mm
                                      (default 0)
    

    在页脚(或页眉)中,您有许多关键字

    * [page]       Replaced by the number of the pages currently being printed
    * [frompage]   Replaced by the number of the first page to be printed
    * [topage]     Replaced by the number of the last page to be printed
    * [webpage]    Replaced by the URL of the page being printed
    * [section]    Replaced by the name of the current section
    * [subsection] Replaced by the name of the current subsection
    * [date]       Replaced by the current date in system local format
    * [isodate]    Replaced by the current date in ISO 8601 extended format
    * [time]       Replaced by the current time in system local format
    * [title]      Replaced by the title of the of the current page object
    * [doctitle]   Replaced by the title of the output document
    * [sitepage]   Replaced by the number of the page in the current site being converted
    * [sitepages]  Replaced by the number of pages in the current site being converted
    

    因此,例如,为了在页脚右侧添加运行页码,您可以在 KnpSnappy 中执行此操作:

    $snappyPdf->setOption('footer-right', '[page]');
    

    【讨论】:

      【解决方案2】:

      ...文档here表示某些标签被替换为例如页码。

      【讨论】:

      • 设置 [page] 不起作用。问题是如何解决的?
      • 我是这样使用的:$snappy->setOption('footer-center', 'Page [page]');
      • --footer-right "Page [page] of [toPage]" --footer-font-size 8
      • @user1254498 该链接已失效。这可能会有所帮助:wkhtmltopdf.org/usage/wkhtmltopdf.txt,主题“页脚和页眉”。
      猜你喜欢
      • 2017-03-19
      • 1970-01-01
      • 2015-01-31
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多