This article shows how to apply page break in group footer which is used to display totals at the group level.
A Page Break or hard page break is a code inserted by a software program (e.g., word processor) telling the
printer where to end the current page and begin the next.
To add a Page break follow the below steps.
- First add a parameter named ‘pagebreak’ on datasource page and choose the connection for it.
- Then on canvas, add a textbox with width=pagewidth and height=2 units, at the group footer where you
want to introduce page break and give it a name that can be easily located in .hcr file, for eg.,
‘abcdef’save the report. - Then open the corresponding .hcr file in Notepad++ from its location and go to line 7. This is
< previewformdata >. Line 6 will be < state >. All changes will be in line 7. - In this first replace all “generateXML”:”false” to “generateXML”:”true”.
- Next search for groups and find the group footer where the page break is applied. Here in this case, the
group is “travel_medium”. Add the following code just after “bandheight”: as shown in screenshot
“groupFooterBandBreak”: {“X”: 0,”Y”: 0,”breakWidth”: 1,”breakHeight”: 1,”printWhenExpression”:
“$P{pagebreak}.equals(\”yes\”)”},In this screenshot, the code is added as highlighted by grey color.
- Then search for the ‘abcdef’ in same < previewformdata > and replace “Y”=0 by “Y”=1 and “textHeight”
=1 by “textHeight”=1 as shown in the screenshot. - Save the .hcr file and then open the report in ‘Open in New Window’ mode.
In the below screenshot, the total can be seen in the next page even though there is space below the records.
Below is the screenshot without pagebreak.
Points to be noted:
- There can be multiple page breaks, only x and y values are to be taken care of.
- There can be page break at any band i.e, details, group footer, summary etc.
- If there is some error in .hcr file, the report will not run properly. So always take a backup of working
report first, then apply backend changes. - If any change is done in the report, then the backend changes are lost and are needed to be done