Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf header on every page

Tags:

wkhtmltopdf

I am using wkhtmltopdf to convert html to pdf.

I want to add header in every page, but it only shows up in the first page (table of contents). The command I am using is "C:\Program Files\wkhtmltopdf\wkhtmltopdf.exe" toc --xsl-style-sheet default.xsl --header-html header.html http://a-url-to-a-page.com "some\folder\outputs\output-%time:~0,2%-%time:~3,2%-%time:~6,2%.pdf"

Any ideas?

like image 756
Shay Ben Moshe Avatar asked May 14 '12 12:05

Shay Ben Moshe


People also ask

How do I create a header and footer in Wkhtmltopdf?

Wkhtmltopdf does support even very complex headers and footers. That command uses the page at www.google.com as a 50mm header for www.stackoverflow.com for every page. Note: If you use a custom page for the header/footer, you need to add <! DOCTYPE HTML> in the beginning of your header/footer HTML!

How do I change page size in Wkhtmltopdf?

Page sizes: The default page size of the rendered document is A4, but by using the --page-size option this can be changed to almost anything else, such as: A3, Letter and Legal.


1 Answers

(Solved by the OP and answered by a question edit. Transcribed here as a community wiki answer - although its a bit terse. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

Finally solved, the problem was that --header-html should come before the table of contents related stuff...

@Nenotlep wrote:

wkhtmltopdf is particular about the order of arguments given.

like image 158
2 revs Avatar answered Oct 10 '22 06:10

2 revs