0
votes

I have a project that I need to complete, and this involves some wkhtmltopdf troubleshooting. So far I have been able to add header and footer dynamically by using "--header-html" and "--footer-html" commands when creating my pdf. The problem that I need help in solving is like my title states. I need to figure out how to call --header-spacing when calling --header-html command.

As of right now, I have tried the following command:

wkhtmltopdf -O landscape -L 0mm -R 0mm --header-spacing 5mm <target-page-url> --header-html "<target-header-location>" --footer-html "<target-header-location>" sample.pdf

wkhtmltopdf -O landscape -L 0mm -R 0mm  <target-page-url> --header-html --header-spacing 5mm "<target-header-location>" --footer-html "<target-header-location>" sample.pdf

Both of these commands result in an error.

Error: Failed loading page http: (sometimes it will work just to ignore this error with --load-error-handling ignore)

If you know how to accomplish this, please let me know.

Thanks in advance.

1

1 Answers

1
votes

I can't duplicate your error message so I'm not sure about this, but I think I got it working. Try a command like

wkhtmltopdf -O landscape -L 0 -R 0 --footer-html footer.html --header-html header.html --header-spacing 5 www.google.com samplex.pdf

Does something like that work for you? wkhtmltopdf is very particular about the order of arguments and I think in this case it a bit confused. Try it with different values for header-spacing like 1, 5 and 10 to see the actual effect it has.