#1484·QuestPDF

PreventPageBreak throws a layout exception if section is bigger than page

Author: sbsrouteurCreated Sep 29, 2026Updated Sep 30, 2026

Describe the bug In a multisection report using a combination of ensurespace at the top to prevent starting a section too low in a page and preventpagebreaks in subsection to try keeping each section complete on a page.

If a section is longer than a full page the prevent page break throw a layout exception. Is this by design? Couldn't this only apply when the section is shorter than a full page?

Expected behavior Below is a sample where the preventpagebreaks have been remove to avoid the layout exception: section 1 respects the ensurespace and starts on the second page. section 2 cannot respect a page break as it is much longer than a page, so the preventpagebreak could be ignored

Image

Screenshots (see above)

Environment Tried with 2025 and 2026.9.0 Win 11 Pro