Search code examples
c#wkhtmltopdfrotativa

Rotativa Page-Break doesn't work


I use wkhtmltopdf 0.12.2.4 together with Rotativa MVC (C#). I used page-break-after: always to generate a page-break. But somehow it doesn't apply the styles to my generated pdf.

Does anyone know how to fix this issue. It seems that Rotativa doesn't have an answer for this issue.

CSS:

.page-breaker {
  display: block;
  padding-top: 120px;
  clear: both;
  page-break-after: always;
  margin-left: 100px;
  z-index: 10;
}

HTML:

<div class="page-breaker">.....</div>

Thx :)


Solution

  • I solved this issue by changing the rotativa and wkhtmltopdf versions to the following:

    Rotativa v1.6.4

    Rotativa.MVC v2.0.3

    Rotativa.Core v2.0.0

    I updated the nuget references in my project. As far as I know Rotativa v1.6.4 works with wkhtmltopdf 0.12.2.1. This version of wkhtmltopdf allows you to do page breaks like so:

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