5
votes

I have a jasper report that consists of 6 subreports. Each of these subreports has its own title section. Now I need each report to start on the new page. I tried adding page breaks but it did not work for me.

While researching the problem I cam across a trick to set isTitleNewPage to true at http://www.dzone.com/snippets/jasperreports-subreport-new. So I added the attribute isTitleNewPage="true" to all the subreports, but now the subreport's Title remains on the previous page and Details and Summary of that subreport are being displayed on a new page.

How can i solve this problem??

6
Why didn't the page breaks work? That should have worked. So did it do anything different, or did it act like there was no page break there? Did you try adding a page break at the top of the Title band in each subreport? That may do the trick.Jacob Schoen
I should better say that page breaks are not completely appropriate in my case. Sometimes page break is being inserted when it is not desired - when there is no space available left on the current page subreport is being carried over to a new page and is followed by a [age break that is specified in jrxml file. It results in a blank page, what is not acceptable.Ihor M.
I do not think there is a solution to this problem. Unfortunately there does not seem to be a way to say "start a new page if not already a new page". The hack you linked only works when the title is blank. As the setting indicates to insert a page break at the end of the title. Do the subreports also have page headers? Maybe you could move the content of the title bands to the page headers, and only have them print on the first page?Jacob Schoen
Some of my subreports span across multiple pages, if I'll add content of the <title/> tag to page header, it will be displayed on each page of that subreport. Is there a way to display page header only on the first page?? Excuse me, i am complete newbie in reporting...Ihor M.
Try setting the PrintWhenExpression for the Page Header band to new Boolean($V{PAGE_NUMBER}.intValue() == 1) in the subreports. That should cause it to only print on the first page of the subreport. I know this expression works when not a subreport, but I am not positive it works with subreports. Basically the subreport sees the page number as.Jacob Schoen

6 Answers

5
votes

Simplest solution is to set runToBottom flag to true in subreport tags.

<subreport runToBottom="true">

This forces the subreport to fill the whole page, so the next subreport will start on a new page.

Flag isTitleNewPage won't do the trick because like you noticed, it will split the subreport's title band with the rest of the subreport content (unless you're using a blank title band).

0
votes

I had the same problem that the title remains on the previous page.

But I have a solution:

  • put the stuff from the title in the "page header" band
  • set isTitleNewPage="true"
  • add a Integer variable to the subreport with the initial value 0
  • inkrement type "page"
  • expression $V{vari} + 1
  • print when expression of the page header is $V{vari} == 0

Now u have your title stuff on a new page, but only one time.

0
votes

My solution to this problem is to add every Subreport in a separate "Detail band" and then set the Band height to the biggest possible value (right click on the "Detail X Band" => "Maximize Band Height"). Between bands could be printed some blank pages, but that is not a big problem in my case.

0
votes

In the initial tag:

<jasperReport

put:

isTitleNewPage="true"

isTitleNewPage

-1
votes

Add a detail band for each sub report and go to the sub report properties and put a tick on Title on a new page.

-1
votes

I solved it by putting a page break at the beggining of each subreport, just before the title label and set 'new Boolean (true)' on the 'Print When Expression' property for each page break.