Fix wkhtmltopdf headers clipping content?

浪尽此生 提交于 2019-12-02 22:45:29

I have learned that this is actually a known issue and is unlikely to be changed in a while. The workaround is to use style="margin:0; padding:0;" in the header <body> element. Another workaround would be to experiment with the --header-spacing n parameter. Yet another way is to wrap all top-page elements and add margin there, but that is a very bad an non-dynamic idea.

For for further information see:

http://code.google.com/p/wkhtmltopdf/issues/detail?id=182 (duplicate of this issue) http://code.google.com/p/wkhtmltopdf/issues/detail?id=175 (the origins of this issue) http://code.google.com/p/wkhtmltopdf/issues/detail?id=523 (header-spacing workaround)

user3536077

Worked for me with <body style='height:50px;overflow:hidden;margin:0;padding:0;'> in the header and footer and the --header-spacing 30 -T 45mm parameters.

Make sure you have <!doctype html> at the start of your header/footer page. Webkit renders the page in quirksmode otherwise.

This worked for me
thead{display: table-header-group;}
tfoot {display: table-row-group;}
tr {page-break-inside: avoid;}

this worked for me

--header-spacing XX -T XXmm

XX should be the same value eq: --header-spacing 20 -T 20mm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!