The --margin-top
option is for the contents margin, but I would like to set the margin from the top of the page to the header. The project I'm working on allows users to create header and footer themselves, so the height of the header or footer is dynamic.
I don't know how to do it so can anyone help?
You can change the header margin too. We do the same thing, we double-click the header area, we press Ctrl+A to select everything inside there. And then we drag that right indent marker about an inch from the edge of the page.
Adjusting the Margin Size of an HTML Element With CSS You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .
The built-in options for top margin are
--margin-top
(as you mentioned above) and--header-spacing
Spacing between header and content in mm (refer: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt). None of them will probably help you as there is no option (at least to my knowledge) that can explicitly set some margin from the top of the page to the header. However, in your case, you could explore --header-html <url>
and add a html header. This can take an HTML where you could probably set the custom header and add space/margin accordingly and then the HTML gets displayed in on the header.
Use -T -B -L and -R for margins.
wkhtmltopdf -B 13 -L 13 -R 13 -T 53 /tmp/e0cb9c4597860b5abfbf2bafc1000d5a.html /tmp/e0cb9c4597860b5abfbf2bafc1000d5a.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With