page number in pdf converted from html - pdfkit, python/django
To add to the above anwser
options = {
'margin-bottom': '0.75in',
'footer-right': '[page] of [topage]',
}
pdfkit.from_string('Hello World', 'out.pdf', options=options)
Will give the output 1 of 2
the following are the other variables can be substituted.
- [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
- [time] Replaced by the current time in system local format
Adding options
should allow for creation of page numbers as follows:
options = {
'margin-bottom': '0.75in',
'footer-right': '[page]'
}
pdfkit.from_string('Hello World', 'out.pdf', options=options)
According to PDFKit's documentation you can use all of wkhtmltopdf's options