Search code examples
jasper-reports

How do I place a record into a new page in JasperReports if it overflows the last one?


I'm using Jaspersoft Studio 6.2.0 and JasperReports 6.2.0 library.

I have a report and in the details section some of the records in the table may overflow a page and the rest of its content is written in a new page. Is it possible to the engine realizes that the content overflows the page and print the whole record as the first one in the next page?

Here is how the report is being generated right now: Here is how the report is being generated right now

What I need is that the last record to be printed in the next page instead of the previous page. Is it possible to achieve this result using JasperReports?


Solution

  • This is normally avoided by using splitType="Prevent" on the JRBand

    Prevent The band starts to render normally, but if the bottom of the page is reached without finishing the band, the whole contents of the band that are already being laid out are moved to the next page. If the band does not fit on the next page, the split occurs normally, as band split prevention is effective only on the first split attempt

    example

    <detail>
        <band height="20" splitType="Prevent">
        ... your text fields ..
        </band>
    </detail>