Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set margin top for header?

Tags:

wkhtmltopdf

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?

like image 665
GordonZ Avatar asked Sep 20 '16 12:09

GordonZ


People also ask

How do I change the header margins in Word?

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.

How do I change the top margin in CSS?

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 .


2 Answers

The built-in options for top margin are

  1. --margin-top (as you mentioned above) and
  2. --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.

like image 102
Ironluca Avatar answered Oct 23 '22 22:10

Ironluca


Use -T -B -L and -R for margins.

wkhtmltopdf -B 13 -L 13 -R 13 -T 53  /tmp/e0cb9c4597860b5abfbf2bafc1000d5a.html /tmp/e0cb9c4597860b5abfbf2bafc1000d5a.pdf
like image 35
tumbudu Avatar answered Oct 23 '22 22:10

tumbudu