[#4975] - Band Element splitType = "Prevent" and Group element keepTogether="true" introduces blank pages

Bug report
Project: Severity:
Component: Reproducibility:
Assigned to:

Band Element splitType = "Prevent" and Group element keepTogether="true" introduces blank page.

When a detail row or group doesn't fit one page, Jasper Report generates a blank page immediately before displaying the content for the long row or group

Package icon keeptogether.zip68.79 KB
Package icon keepTogether_issue.zip4.04 KB
Package icon moreExamples.zip8.5 KB
dgonsalves's picture
Joined: Nov 15 2010 - 12:10am
Last seen: 11 years 8 months ago



Even if there is a work around for this problem, it would do for now as this is very urgent for my application and is blocking on the usability of the App


I have detected the same problem, or very similar. I my case, the blank page should contain items but they are missing. To reproduce the error (in iReport), I have uploaded here the invoice_activities.jrxml with the input one_short_one_long.csv and the result one_short_one_long.pdf. Curiously, there are input cases where the output is correct, see one_long.csv and one_long.pdf.

I use the current version 3.7.6. I agree with dgonsalves that this issue is urgent. Currently, the keeptogether option is practically inoperative because of "items swallowing" risk.


Can someone atleast please acknowledge this from Jasper and look into this.

This is obviously a report breaker (atleast in my case) and I am finding it very hard to get around this.


Finally I have atleast found the solution for splitType=Prevent issue on the band.


Simply use the deprecated property isSplitAllowed="false"

and everything works well :)


Unfortunately, this is not a workaround in my case (try keeptogether.zip).


Apparently the blank page issue still exists even now.

It seems the blank page issue was not solved because of the property isSplitAllowed="false'.

It was some certain scenario with data in certain format that the blank page did not appear.

As of now the blank page continues to appear even after using the old property :(

Hope someone finds a solution to this


I think I found the exact issue with Jasper.

This happens when SplitType=Prevent or keepTogether=true for a band or group.

The behavior of Jasper is such that if an element or row is going to flow into the next page, it prints it on the next page instead of the same page.

This is normal behavior if the row or element is not the first element of the dataset or group. However, this creates a problem if the element or row that is going to overflow is the first element of the dataset or the first element of a group.

When the first element or row of the dataset or the group is too huge to fit in a single page, jasper leaves the current page and prints it on the next page creating a blank page (on the first page of the report or first page of the group respectively)

I hope the Jasper team figures this out quickly and provides a solution or work around.



I have committed a fix on SVN.
Can you please give it a try and let us know how it goes for you?

Thank you,

commit -m "mantis #4926 : fix keepTogether for groups starting on new page/column" /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRBaseFiller.java /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRHorizontalFiller.java /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRVerticalFiller.java
Sending /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRBaseFiller.java
Sending /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRHorizontalFiller.java
Sending /home/dori/Programs/eclipse/workspace/jasperreports/src/net/sf/jasperreports/engine/fill/JRVerticalFiller.java
Transmitting file data ...
Committed revision 4095.


I was facing this similar data missing issue. With the latest code taken from jasperreport svn, the data missing issue seems fixed.But still there remains a potential problem related to this issue.

To summarise, I have a master report and in that master report, I have subreport. The subreport has lots of detail bands. These detail bands are grouped under a report group. For the group the properties are set as follows:
splitType - Prevent
keepTogether - true
groupExpression - $V{REPORT_COUNT}

While generating report, the subreport detail bands cannot split, as I have set the group property keeptogether as true. But this does not work for the first time, in a scenrario where the master report has rendered some content on the page and by the time when subreports started its printing, it could not fit the details section in the page. The expected behaviour is that, the subreport has to leave the remaining page as blank, and then start rendering from the new page, so that the whole details section of subreport will not break. But it is not working as expected. Instead the subreport starts printing the subreport details section from the avaiable space in the previous page, then breaks, as there is no space in the current page. Then it prints the remaining portion of the detail band in the next page. But however after this first time, the keeptogether works properly for the remaining section of the report. Which means, if the subreport could not print the whole detail section in the page, it leaves the page blank and moves to the next page to print.

I have attached a zip file keepTogether_issue.zip, containing the jrxml files and the PDF file I have created, that has this issue.

This is a blocker for my report generation. Please clarify us on this issue.


Please refer to my notes regarding the side effect caused due to this fix.Looking forward for your reposnse on this.

Thanking you in advance.


Hi Teodord,

Thanks for the fix.

It will be really great if you can please clarify the following:

1) Can you please let me know if this fix will also work for splitType="Prevent" on the band.

2) Also, where can I download the nightly builds(jars) of Jasper.

3) currently, I am using Jasper 3.5.3. Are there any other libraries I will have to upgrade for using this new version.

Thanks and Regards,


Hi Teodord,

I downloaded the source from svn and created the jasper build.

After running testing against this new build, I found the issue for splitType="Prevent" still exists.

As per your commit notes'commit -m "mantis 0004926 : fix keepTogether for groups starting on new page/column"', it seems that the fix is for keepTogether=true and not for splitType="Prevent".

Also, the issue 4926 is for keepTogether=true and not splitType="Prevent".

This issue 4975 was raised for splitType="Prevent" and keepTogether="true"

Can you please fix the issue for splitType="Prevent".

Many Thanks and Regards,



Ideally, you should log a different bug for each different issue. Should not merge two issues into a single bug.

What I have fixed, is for the keepTogether group problem that I was able to reproduce and thus fix.
I am not aware of any current problem with splitType="Prevent" and you would have to attach some files that would help us identify it.

I suggest you log a different bug for it as this one has pretty much transformed into a keepTogether only issue.




In your attached example with the subreport, do you expect that the blue column header to go on the second page?

Waiting for your answer, I can only say that the keepTogether feature is not supposed to work outside the report template that it is used.
If you use it for the group defined inside the subreport, it does not prevent the group from appearing on the first page, because that is the first page of the subreport instance and inside the subreport it is already a new page, no reason for starting yet another page. The subreport does not know that the master report has alredy generated content on the first page. The subreport keeps track of its own "internal pages" with regards to keepTogether flag.

It was supposed to work like that by design and it is not a newly introduced bug. If you want to prevent your subreport from splitting, you should mark the detail band in the master (that contains the subreport) with splitType="Prevent".

I hope this helps.


Hi Teodord,

I really dont understand how this issue transformed into the keepTogether issue when the summary and description of this issue clearly describes it to be for first splitType="Prevent" and also for keepTogether.

'Band Element splitType = "Prevent" and Group element keepTogether="true" introduces blank pages'

The only reason, I added these two into this issue was because it seems to be a generic problem when jasper trys to prevent a row or group from splitting across two pages.

However if for some reason, you feel I should create another issue for this, i will do the needful.



I have created a new issue 0005010 for the splitType=true issue.


Hi Teodor,
Thanks for the info.
My answer regarding the attached example is, Yes...I expect the blue column header to go to the second page.

For the same example, ie I have retained the master template detail band as splitType="Stretch" and subreport group keeptogether as true. But now I have reduced the static contents on the master templates, to see how the keeptogether of the subreport behaves.In this case, I see the first subreport detail band content fits into the first page and so it prints in the first page. The second subreport detail band contents cannot fit into the first page, due to space constraint. So it moves to the second page and prints from the second page. As per the info, you have given, I was expecting the subreport second record detail band content to start from the first page itself. But it was not. Please refer the "SampleReport_withMasterBand_Split.pdf" file I have attached.

Also I followed your advice to make the master report band, that contains the subreport as splitType="true". But in this case, even if there is space to print the subreport detail band contents in the first page, the subreport details band contents move to the next page to print. This causes the first page to have a huge blank space. Please refer the "SampleReport_withMasterBand_SplitPrevent.pdf" file I have created.

In my case, I have multiple datasource, thats the reason, I have gone for subreport. Please let me know, how can I make JasperReport work, for my requirement.

Thanks in advance,


Hi, Dinesh

Not sure why you expected the second record to be on the first page in the "SampleReport_withMasterBand_Split.pdf". That second record is in the second group and since the group is not allowed to split and the subreport page is no longer new/empty (because it already displayed the first record group), then it has to go on the second page.

In any case, all your samples work like expected, including the one in which you made the splitType="Prevent" in the master. When you mark a band with splitType="Prevent", the engine prefers to start the band on a new page, before splitting it. This is exactly what it does when you see that big blank space. I don't know what you expected.

I think continuing the discussion in this way would not get us anywhere fast. You have to better explain what you need to achieve, instead of explaining how you think things should work.
If you explain what you need to obtain, maybe I can tell you what settings to use. So far all settings you have tried worked as they were designed, from my point of view, but you expected them to work differently and I don't understand in which way exactly.

So let's try this differently. Tell us what you need to achieve and we'll try tell you how to do it.



Hi Teodord,
Thanks a lot for your reply. As you have suggested, let me explain my requirement.

My template has to handle 2 datasources, in order to display the contents. So I pass the 1st datasource to the main template. To handle the 2nd datasource, I am using the subreport to display the data. The datasource to the subreport is of type JRBeanCollectionDataSource. This collection datasource has a list of POJO objects. My POJO has 40 getter methods. For each getter method I have created 40 detail bands in the subreport. This 40 data that prints one below the other should stay together ie it has to fit in a single page and there should not be page break in between them. So the first POJO from the datasource generates a set of 40 rows, 2nd record generates a set of 40 rows etc. Each set should never break while printing in a page. Also this subreport will print the data just after the main report data contents.

My actual requirement is as follows:

Scenario 1: The main report datasource prints the data in the 1st page. If there is enough space available in the first page to display the first record of subreport, which has to stay together, then the subreport has to print the POJO data in the first page. And again, if there is enough space to display 2nd POJO record in the 1st page, then display the 2nd POJO data of subreport in the 1st page. But if there is no enough space to print the 2nd POJO, then print it in the 2nd page. Like wise it proceds for the remaining POJO records.

Scenario 2:
The main report datasource prints the data in the 1st page. But in this case the 1st page does not have enough space to display the 1st POJO record of the subreport. So the remaining space of the 1st page has to be left blank and the 1st POJO record of the subreport should start from the 2nd page. Like wise it has to proced for the remaining POJO records in the sunreport.

It will be of great help, if you can let me know to achieve this.

Thanks in advance.




At this point, it is impossible to make the keepGroup flag take effect on what is basically the first page of the subreport. The engine considers that to be a new page already and thinks there is no point in creating yet another new subreport page.

I'm not sure if we are going to attempt doing anything about this in future versions, as the keepGroup together flag is not "subreport-aware" let's say.

But in the meantime, I suggest you try the minHeightToStartNewPage property of the group, which might be useful to force the first instance of the subreport group to start on a new page.

I hope this helps.



Feel free to reopen this is the minHeightToStartNewPage solution did not work for you.

Actually, I would prefer you create a new tracker, so that we track the precise remaining problem, without reading through this long thread.

Thank you,


Hi Teodor,
The minHeightToStartNewPage solution does not work for me to address my requirement. As you have suggested, I will raise a new ticket for the subreport keepTogether issue.
Thanks for your suggestion.


  • Status:Resolved» Closed

Soon when you have this problem, do not look anymore on this side.

The simplest is to use the "break". A method :

* put the break component on the first detail and go to the property "print when expression: $ V {PAGE_NUMBER}> 1"

* then create another detail to put your work on.

I hope I have helped a few.



Just to let you know that with the upcoming release, the newly introduced minDetailsToStartFromTop property added to groups, would cause the group to start on a new page/column even if the current page/column is new, as it is the case at the start of subreports. Basically, setting a value hight enough for minDetailsToStartFromTop, would cause it to work more like keepTogether, except the break will occur every time the condition is not met, including page/columns that are already new.

I hope this helps.

  • Priority:Urgent» Immediate
  • Severity:Block» Critical
  • Resolution:Fixed» Open
  • Status:Closed» Assigned
  • Assigned:nobody»