Fix wkhtmltopdf headers clipping content?

余生长醉 提交于 2019-12-03 08:46:11

问题


My headers often clip content so that the content below it is not completely visible, it appears as though the page continues underneath the header before the header ends and as a result, not all of the content is shown.

Is there a CSS rule I can use for this? Or a cmd argument for wkhtmltopdf? Or any other way?


回答1:


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)




回答2:


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.




回答3:


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




回答4:


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




回答5:


this worked for me

--header-spacing XX -T XXmm

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



来源:https://stackoverflow.com/questions/11447672/fix-wkhtmltopdf-headers-clipping-content

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