I found the solution: I created a bash script who isolates the header in a HTML file then inject it with --header-html
Edit:
Assume that your header is in thead tag
filename="x.html"
begin=`awk '/<thead>/{ print NR; exit }' $filename`
end=`awk '/<\/thead>/{ print NR; exit }' $filename`
echo "<DOCTYPE! html>" > $filename".head.html"
cat $filename | head -$end | tail -n +$begin | sed -e "s/.*<thead>/<thead>/g" | sed -e "s/<\/thead>.*/<\/thead>/g" >> $filename".head.html"
#You can do the same for tfoot
wkhtmltopdf --header-html $filename".head.html" $filename output.pdf
it works also for tfoot or in the case of the header and the footer are in header tag .
you also need to make a style tag in the original document to say that display is none . ( you can add this by a script )
<!doctype html>
solution, eliminating any need to play with margins and other things like those; or just directly skipped to test that solution as yours already worked. Testing that solution also means clearing weird CSS things one might previoulsy had. You own the question, you own your choose of the anwer. [continues] – Seat!doctype
does not solve your issue, it's okey. I had exactly your problem, and that solution exactly worked for me, and it's simply "pure", no hacks. Your question, you choose the answer; of course. – Seat