Snappy & wkhtmltopdf: нумерация страниц в нижнем колонтитуле

Я хотел бы иметь номер страницы в нижнем колонтитуле каждой страницы, созданной с помощью Snappy и Wkhtmltopdf, но я не нашел никаких подсказок об этом.

Я могу установить текст нижнего колонтитула (с параметрами «нижний колонтитул»), но как указать номер страницы?


person qdelettre    schedule 04.03.2014    source источник


Ответы (2)


... документ здесь указывает, что некоторые теги заменяются, например, номером страницы.

person qdelettre    schedule 05.03.2014
comment
настройка [страница] не работает. Как решилась проблема? - person Gogol; 18.11.2014
comment
Я использовал это так: $snappy-›setOption('footer-center', 'Page [page]'); - person qdelettre; 18.11.2014
comment
@ user1254498 эта ссылка не работает. Это может помочь: wkhtmltopdf.org/usage/wkhtmltopdf.txt, раздел Нижние колонтитулы и заголовки. - person userfuser; 25.10.2019
comment
Проголосовали за мертвую ссылку. - person Bananaapple; 01.02.2021

Добавление этого в качестве принятого ответа - это всего лишь ссылка 404.

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]');
person Bananaapple    schedule 01.02.2021