Having an issue when converting a HTML page to a PDF using NReco, where div's with the style 'page-break-before:always;' will not leave a page break when it's converted to a PDF.
Below is the code that actually converts the html to PDF
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
Response.ContentType = "Application/pdf";
Response.BinaryWrite(pdfBytes);
Response.End();
Below is a segment of HTML
</div>
<div>
<h3 style="page-break-before:always;">
Forsikringsbevis fortsat
</h3>
<!-- Second large table -->
<div>
Below is a screenshot of the pdf without the pagebreak.
I figure that for some reason the CSS isn't getting picked up, however other CSS is being displayed on the page, like the colouring for example.
Any ideas?
In case of wkhtmltopdf, when you specify element with 'page-break-before:always;' it should NOT be inside table or floating elements. In other words, this should be top-level element inside <body>.
In case of table, it is not possible to force page break manually inside table, but it is possible to prevent breaks inside table cells.