Wkhtmltopdf margin (top and bottom)

Kwarkjes picture Kwarkjes · Jun 1, 2012 · Viewed 10.2k times · Source

I am using wkhtmltopdf 0.10.0 rc2 on a: Linux 3.2.0-24-generic #38-Ubuntu x86_64 GNU/Linux

I can't create PDFs with margin-top or margin-bottom (no errors)

I'm using the command below:

wkhtmotopdf -T 50 -B 50 http://google.com ./test.pdf
wkhtmotopdf --margin-top 50 --margin-bottom 50 page.html ./test.pdf

When I try this:

wkhtmotopdf -L 50 -R 50 -T 50 -B 50 page.html ./test.pdf

Margin left and right works perfect (still no margin-top or margin-bottom). It doesn't matter which URL or page I convert.

EDIT:

It looks like it's a bug. For the people who still want some margin-top/margin-bottom. Try using the header-html/footer-html feature:

Just realised that the clipping problem is fixed by adding the header-spacing and footer-spacing parameters:

wkhtmotopdf -L 50 -R 50 -T 50 -B 50 http://google.com --header-html blank.html --header-spacing 5 --footer-html blank.html --footer-spacing 5 ./test.pdf

Answer