How to limit jaspersoft sub-report output to only one page.
search cancel

How to limit jaspersoft sub-report output to only one page.

book

Article ID: 409061

calendar_today

Updated On:

Products

Clarity PPM SaaS Clarity PPM On Premise

Issue/Introduction

Is there a property or parameter when invoking the sub-report that will say "only print the first page"

Resolution

In Jaspersoft, there is no direct "print only first page" property or parameter for a subreport itself. However, you can achieve this effect by using a printWhenExpression on the subreport element within your main report. 
 
Workaround:
  • Locate the Subreport Element:
    In your main report's JRXML, find the <subreport> element that defines where your subreport is placed.
  • Add printWhenExpression:
    Within the <reportElement> tag of your subreport, add a <printWhenExpression> tag.
  • Use $V{PAGE_NUMBER}:
    Set the expression to check the current page number of the main report. The built-in variable $V{PAGE_NUMBER} provides this value.