Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't wkhtmltopdf page-break-after have any effect?

Tags:

wkhtmltopdf

I'm using wkhtmltopdf 0.10.0 rc2 for Mac

I have an html like this one :

<!DOCTYPE html> <html lang="en">   <head>     <meta charset="utf-8">     <link href="print.css" rel="stylesheet">     <style type="text/css" media="screen,print">       .break{         display: block;         clear: both;         page-break-after: always;         border :1px solid red       }       .page-breaker {       display: block;       page-break-after: always;       border :1px solid red       }     </style>   </head>   <body>     <div class="container break">       page 1     </div>     <div class="page-breaker"></div>     <div class="container">       page 2     </div>   </body> </html> 

I simply try :

wkhtmltopdf test.html test.pdf 

But it didn't produce a page-break, I doing something wrong ?

like image 254
Awea Avatar asked Dec 03 '12 21:12

Awea


1 Answers

Possibly unrelated as your pdf generated ok with an earlier version of wkhtmltopdf. Either way, I had similar issues with page breaks not being applied correctly. My problem was parent elements of the page-breaked element having an overflow other than visible. This fixed my issue:

* {   overflow: visible !important; } 

Of course, you can be more specific about the tags this applies to ;)

like image 72
David Martin Avatar answered Sep 24 '22 19:09

David Martin