问题
Im using wkhtmltopdf --header-html option, but it seems, that it really works only with html code. Is there any way I can add some PHP and force it to working somehow? I need to display Date and user´s e-mail on every page... Thanks for any advice ;)
回答1:
You can feed --header-html almost anything :) Try the following to see my point:
wkhtmltopdf.exe --margin-top 30mm --header-html isitchristmas.com google.fi x.pdf
So isitchristmas.com could be www.yoursite.com/magical/ponies.php
Just to add, you cant run the php files locally so you need a webserver to serve them. If you need 100% local dynamic headers you could try some fake dynamic with javascript; use --header-html myheader.html?date=12345&usermail=derp
and then process the URL with javacript (I havent tried it).
回答2:
To add extra query string parameters for your header/footer html you need to use the command line switch 'replace'.
The wording of the help/manual is a little misleading (i.e. better wording would have cleared up the issue), as it lead me on the wrong path (tried using the 'post' switch). I found the solution after digging through the code on github.
来源:https://stackoverflow.com/questions/11981853/wkhtmltopdf-is-possible-to-display-dynamic-headers