Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snappy & wkhtmltopdf : page numbering in footer

I would like to have the page number in the footer of every page generated with Snappy and Wkhtmltopdf, but i haven't found any clue about it.

I can set a footer text (with options 'footer-center') but how to put the page number ?

like image 673
qdelettre Avatar asked Mar 04 '14 13:03

qdelettre


People also ask

What's meaning of snappy?

Definition of snappy 1 : snappish sense 1. 2a : quickly made or done a snappy decision. b : marked by vigor or liveliness snappy dialogue. c : briskly cold. d : stylish, smart a snappy dresser.

What can I get on snappy?

You go to Snappy Gift's app, choose a price range and then select from a collection of gifts your recipient will choose from, like 'gadgets', 'cooking', 'outdoors' or 'teens. ' You can then designate a suggested gift from legit brands like DJI drones, Amazon mobile devices, GoPros, Prada clothing and Kate Spade purses.

What is an Amazon snappy gift?

Snappy's unique approach lets you to choose a personal and thoughtful gift from a curated collection of amazing products, while allowing your employees the flexibility to choose an alternative - so they always get a gift that they love! See our gift collections.

Is Snappy an adjective?

adjective, snap·pi·er, snap·pi·est. apt to snap or bite; snappish, as a dog. impatient or irritable, as a person or a reply. snapping or crackling in sound, as a fire.


2 Answers

... the doc here indicate that some tags are replaced with, for example, the page number.

like image 99
qdelettre Avatar answered Sep 25 '22 06:09

qdelettre


Adding this as the accepted answer is just a 404 link.

Wkhtmltopdf gives us a number of options for controlling where to put the footer text, according to the documentation:

  --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)

Within the footer (or header) you then have a number of keywords

* [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

So for example, in order to add a running page number to the right of the page footer you can do this in KnpSnappy:

$snappyPdf->setOption('footer-right', '[page]');
like image 27
Bananaapple Avatar answered Sep 25 '22 06:09

Bananaapple