How can I start content on a new page if it doesn't fit

3.2k Views Asked by At

I'm using Pechkin to convert html content with css to pdf files.

The problem I am facing is that a part of a html block is being cut off because it doesn't fit on the current page anymore.

Now what i would like is that when the content doesn't fit on the current page that it creates it on the next page.

Is this possible with Pechkin?

Code:

var pechkin = new SynchronizedPechkin(new GlobalConfig());
return pechkin.Convert(new ObjectConfig()
                         .SetLoadImages(true).SetZoomFactor(1.5)
                         .SetPrintBackground(true)
                         .SetScreenMediaType(true)
                         .SetPrintBackground(true)
                         .SetCreateExternalLinks(true), html);

Problem

2

There are 2 best solutions below

2
Jamie On BEST ANSWER

Instead of using float elements I switched to inline-block elements. I gave the inline-block elements the style: page-break-inside: avoid; and it now knows when to start on a new page.

0
Nic On

A way to add page breaks is by injecting CSS into your HTML.

<div style='page-break-after:always'></div>

If you want to prevent certain HTML blocks to be cut off you can try wrapping the with this div (or apply the style to your existing code block:

<div style='page-break-inside: avoid;'></div>