Page break problems

455 views
Skip to first unread message

Ester Ytterbrink

unread,
Sep 24, 2014, 8:11:01 AM9/24/14
to wkhtmltop...@googlegroups.com
Hi!
I am running wkhtmltopdf 0.12.1 (with patched qt) on OSX 10.9.5 and want to have each section starting on a new page. 
My plan was that <div class="page-break"></div> would cause that when inserted where I want the page breaks.
The css says:

.page-break {
    display:block;
    clear:both;
    page-break-after:always;
  }

But it does not break the page. 

Any idea what could be wrong? That solution seems to work for everyone else. 

br. Ester

Yozons eSignForms

unread,
Sep 24, 2014, 2:08:03 PM9/24/14
to wkhtmltop...@googlegroups.com
You might try adding &nbsp; inside the div as some (most?) browser ignore empty elements and may even remove them from the DOM. 

We use:

CSS: div.newPage { page-break-after: always; }

HTML: <div class="newPage">&nbsp;</div>


mn4367

unread,
Sep 25, 2014, 5:21:06 AM9/25/14
to wkhtmltop...@googlegroups.com
This HTML works as expected here:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
    <style type="text/css">

        .page-break {
            display:block;
            clear:both;
            page-break-after:always;
        }
      </style>
  </head>
<body>
    <p>On first page.</h1>
    <div class="page-break"></div>
    <p>On second page.</h1>
  </body>
</html>


Maybe other CSS selectors in your document prevent page breaking?

If you can post your complete document containing and all related resources it would be easier to investigate this.

Ester Ytterbrink

unread,
Sep 26, 2014, 4:21:20 AM9/26/14
to wkhtmltop...@googlegroups.com
Thank you!
I found my problem.position: absolute; do not play well with page-breaks. With that removed it works like a charm. 
br. Ester
Reply all
Reply to author
Forward
0 new messages