Jump to content

How to make the report engine adjust band height to fit the real space occupied by content?


Recommended Posts

I have couple of lines of text that must be printed above the <detail> section (i.e. under the regular <title> and <pageHearder> section) and only on the first page. My currently solution is to place the text as the bottom part of the <pageHearder> and use printWhenExpression(PAGE_NUMBER = 1) to make them only appear on the first page. This solution works fine for the first page but the problem is that for the rest of pages the space that is reserved for the text become an ugly blank block. Is there some way to make the report engine dynamically and automatically adjust the height of a band to eliminate the blank blocks when not all its contents get printed? Or there are other ways to solve problem? I searched the web and found this post  asked almost exactly the same question as mine but the solution in its reply does not work.
Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for your suggestion. Unfortunately my report has multiple columns.
I don't understand why jasper uses so static band height. If it could support something like height="*" to indicate the height is as mush as needed that would be great.

Post Edited by sunnyramon at 02/07/2011 19:26
Link to comment
Share on other sites

Yes, dynamic values for attributes are still a problem, indeed. But not the variable band height. It can be solved with stretch attributes.

  1. ensure that splitType attribute of the pageHeader is set to "Stretch"
  2. put all text that needs to be printed on the first page only in one or more textfields having  isStretchWithOverflow="true", and height="1" (this height will be dinamically increased at fill time)
  3. for textfields at point 2, write the printWhenExpression too
  4. calculate your pageHeader band height considering that the textfields at point 2 have exactly height="1"

I think that this should solve the problem.

Please also to consult the stretch sample in order to find out more about how to combine a series of stretch attributes in order to get the optimum report layout.




Post Edited by shertage at 02/07/2011 20:50
Link to comment
Share on other sites

  • 1 year later...
  • 11 months 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...