Using different margins for cover/toc/page ?

1,711 views
Skip to first unread message

Jean-Charles Longuet

unread,
Mar 18, 2017, 9:49:11 AM3/18/17
to wkhtmltopdf General
I generate a document with headers and footers on every page, with margin space set with --margin-top /--margin-bottom options. I also want to add a cover without any margin. All the --margin-* options seems however to apply to the full document only, not to specific parts..

  1. Is that correct or are there ways to specify different margins for every section ?
  2. Are there alternatives/hacks to achieve what I want without involving other tools ? I do deal with the left and right margins with specific css, but I could not find a way to deal with top/bottom margins on every page.

For information, I can modify most of the HTML and css files, and I use wkhtmltopdf 0.12.4 (with patched qt) on Windows 7 with the following command :

wkhtmltopdf.exe \
--page-size A4 \
  --dpi 200 \
--margin-top 30mm \
--margin-left 0mm \
--margin-right 0mm \
--margin-bottom 24mm \
--header-html ./my-header.html \
--footer-html ./my-footer.html \
--outline-depth 3 \
cover \
  ./my-cover.html \
toc \
--xsl-style-sheet my-toc.xsl \
   page \
    TOTS.html \
--print-media-type \
my.pdf

Jakob Truelsen

unread,
Mar 19, 2017, 7:44:28 AM3/19/17
to wkhtmltop...@googlegroups.com
The margins are managed by the qt print system, so we cannot change
them on a page to page basis afaik, why not just use another tool to
slap on the front page (pdftk?)

/Jakob
> --
> ===================================================
> You received this message because you are subscribed to the "wkhtmltopdf
> General" group.
> To post to this group, send email to wkhtmltop...@googlegroups.com
> To unsubscribe from this group, send email to
> wkhtmltopdf-gen...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/wkhtmltopdf-general?hl=en?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "wkhtmltopdf General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to wkhtmltopdf-gen...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jean-Charles Longuet

unread,
Mar 19, 2017, 1:31:06 PM3/19/17
to wkhtmltopdf General
Thanks Jakob. I considered pdftk but this adds another tool in the pipeline, and it is likely to break the outlines and/or links.
Setting all documents margins to zero and adjusting non-cover top and bottom margins through css was not successful either (@page does not seem to work).
I will probably adjust the cover design and colors to deal with margins, unless a clever css trick can save me.

--
Jc
>
> For more options, visit this group at
> http://groups.google.com/group/wkhtmltopdf-general?hl=en?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "wkhtmltopdf General" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Tiana Miletic

unread,
Aug 8, 2023, 10:02:48 AM8/8/23
to wkhtmltopdf General
Hello
Have you found the solution to this problem?
I'm in the same situation, I can't get rid of the top and bottom margins for my cover.
Reply all
Reply to author
Forward
0 new messages