简体   繁体   中英

How to place --header-html above margin-top with WKHTMLTOPDF

I have a (in my opinion) common scenario where I want to print a header with a logo on every page. The text on the document can overflow and needs to start on the second page below the header. The logo should start at 10 mm from the top. The text on the second page should start at 40mm from the top of the second page. If I specify top-marin -T 40mm then the header starts at 40mm also. If I specify -T 10mm then the text starts at 10mm also. I have tried to position the header with a CSS style attribute at "position:absolute;top:10mm" from the top and -T 40mm, and I have also tried to position using "margin-top:-30mm" but none of these work. Printing outside the specified margin parameters seems to be impossible. Am I missing something? The --footer-html is placed under the specified bottom-marign -B, why is the header not placed above the top margin?

I've discovered the problem. First of all the header-html file needs a !doctype html, just like the body part. Next, after adding a position:absolute;bottom:10mm; style attribute to the header, it appeared beautifully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM