Jump to content
We've recently updated our Privacy Statement, available here ×

Subreport causing empty page


saust

Recommended Posts

Hi,

I have a two page report with a subreport on each page.  When both subreport are displayed everything works fine.  However, when the second subreport is suppressed, I still get two pages one of which is blank.  I use runToBottom=true for both subreports (so that they are on a seperate page with footers at the appropriate place), there's no space between the subreports or after the last one, and I checked remove Line When Blank.  Anybody got an idea of what I am missing?  I included part of the xml code below.

Thanks, Ann.

 

 

Code:
<summary>        <band height="12">            <subreport runToBottom="true">                <reportElement positionType="Float" x="0" y="0" width="540" height="6" isRemoveLineWhenBlank="true"/>                ...... lots of parameters.....                <subreportExpression class="java.lang.String"><![CDATA[$P{basePath} +      "Darssa2ConsumerIntake_PFR1.jasper"]]></subreportExpression>            </subreport>            <subreport>                <reportElement positionType="Float" x="0" y="6" width="540" height="6" isRemoveLineWhenBlank="true">                    <printWhenExpression><![CDATA[$V{showDrugPage}]]></printWhenExpression>                </reportElement>    ...... more parameters.....                <subreportExpression class="java.lang.String"><![CDATA[$P{basePath} + "Darssa2ConsumerIntake_PFR_drugs.jasper"]]></subreportExpression>            </subreport>        </band>    </summary>
Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

Using JasperReport / iReport 3.7.0.

I too am seeing an issue with a blank page coming out when using the 'Run to bottom' property on the subreport.  When the 'Run to bottom' is true, the footer in the subreport comes out at the bottom of the page, but a blank page comes out after it. When the 'Run to bottom'  is false, the footer in the subreport is not at the bottom of the page, but no blank page.

Seems to be a bug in using the 'Run to bottom' property.  It seems the Footer Position property also causes this 'bug'.

Link to comment
Share on other sites

Thanks for your input.  I hadn't noticed a problem with the footer position.

After many attemps, I also concluded that it seems to be a bug with runToBottom.  It doesn't matter what the following suppressed item is (a suppressed label will cause the same problem).  Perhaps the page break following runToBottom is evaluated before determining whether the following code should be printed or not?  I ended up fixing the problem with 2 copies of my subreport, one with runToBottom=true used for multiple page reports and one with runtToBottom=false for one page reports. Of course, I then had a footer problem on the one page report, so I had to add it all to an extra top report file with a footer only used for the one page report.   

Ann.

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

 Hi 

I haven't found a solution yet but the behavior seem to be very specific.

If the actual output of the subreport is taller that the height of the subreport design element, then it will force a new page.

I've tried various combinations of stretch and report size but no solution yet.

-- Dave

Link to comment
Share on other sites

  • 5 months later...

Hi,

 

In the first case at the top of this thread, the blank page was probably caused by "an overflown with white space". The 6 white pixels resulting from the suppression of the second subreport, overflow onto the next page, because the first subreport was precisely big as a whole page. So the extra 6 pixels did not fit.

 

Same thing probably happens in case the first subreport has runToBottom and it forces the remaining white space in its conaining band to overflow onto a new page.

 

To avoid such problems, I suggest subreports to be placed in separate bands and to use the printWhenExpression of the band instead of the subreport element to suppress them.

Note that a summary band could be split into multiple bands by using dummy groups footer bands. Groups that null or constant expression so they break only once per report.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

  • 3 years later...

I think that i get this work. Setting height="0" for band and subreport element solved problem.

<band height="0">
 <printWhenExpression><![CDATA[$P{show1}]]></printWhenExpression>
            <subreport runToBottom="true">
                <reportElement positionType="Float" x="0" y="0" width="595" height="0"/>            
                ...
            </subreport>
</band>
        <band height="0">
            <printWhenExpression><![CDATA[$P{show2}]]></printWhenExpression>
            <subreport runToBottom="true">
                <reportElement positionType="Float" x="0" y="0" width="595" height="0"/>            
                ...
            </subreport>
        </band>
        ...

 

Link to comment
Share on other sites

  • 2 months later...

Yes, this is the solution.

No need to use runToBottom for this to work.

 

In the main report if you specify subreport height value other than 0, jasper report will still generate a blank area with that minimum height even if the subreport has no data.

 

All subreports height will be accumulated with other group and section band heights, if the total height is greater than main report page height, jasper report will put the remaining element to next page which generates a blank page.

 

Don't worry about setting subreport height=0, if subreport has data it will be displayed in main report and the height will be adjusted automatically.

Link to comment
Share on other sites

  • 3 years later...
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...