0

I have a "parent" jrxml, let's call it "class", that looks like this:

<band height="100" splitType="Prevent">
  <textField isStretchWithOverflow="true">
  <textField isStretchWithOverflow="true">
  <subreport>
    <subreportExpression>
      <![CDATA["student.jasper"]]>
    </subreportExpression>

has n subreports, one for each "student". The "student" subreport is just some textfields.

<band height="35">
  <textField isStretchWithOverflow="true">
    <textFieldExpression>
      <![CDATA[$F{first_name}]]>
    </textFieldExpression>
  </textField>
  <textField isStretchWithOverflow="true">
    <textFieldExpression>
      <![CDATA[$F{last_name}]]>
    </textFieldExpression>
  </textField>

What I would like to do is print a "This class continues in the next column/page" message at the bottom of the column if the content doesn't all fit in the one column.

Is this possible with JasperReports?

Robert Bowen
  • 487
  • 2
  • 13
  • 24
  • 1
    [i-want-continue-text-when-sub-report-will-overflow-to-new-page](http://stackoverflow.com/questions/31562288/i-want-continue-text-when-sub-report-will-overflow-to-new-page) – Petter Friberg Mar 23 '16 at 20:30
  • Thanks for that link, it helped me immensely. But it doesn't work in all cases. What's happening at the bottom of many columns (I am using a 3-column report) is that if the *next* Class doesn't fit in the space left, it starts on the next column but, since I have "... continued" in each Class's footer subreport, it's printing "... continued" at the bottom of the column. Making it seem that the current Class is continued in the next column, but it is in fact the next Class. Not sure if there is way to tell Jasper to not print the footer in this case ... – Robert Bowen Mar 29 '16 at 14:39
  • Its difficult to say without an [mcve], but printWhenExpression?? – Petter Friberg Mar 29 '16 at 14:54
  • Well I can't really supply an example because the reports themselves use custom Java Objects (wrappers) that I can't make public. Suffice to say the solution doesn't work. What I need is a , at the subreport level, that is only displayed when the current subreport's content overflows into the next column/page. I've tried , and and none of them seem to be able to do this. And neither can I find a that can help; there's nothing in the api that tells you if content will overflow. But thanks for you help. – Robert Bowen Mar 31 '16 at 16:03
  • Can't you make an simple example with some cvs data?, strip it down some data in cvs and a simple jrxml. I don't know if it can be solved but atleast the community can exactly understand your problem and try to find a solution. – Petter Friberg Mar 31 '16 at 16:05
  • Just to show you how see this example http://stackoverflow.com/questions/36306170/how-can-i-export-report-to-pdf-a-1a-pdf-a-1b – Petter Friberg Mar 31 '16 at 16:07
  • Well the problem isn't the data, the problem is the rather complex (and crappy) way data is given to the subreports, using these klunky wrappers that are old, legacy Java code that unfortunately I can't make public because it's my company's intellectual property. What I would need to do is re-do the reports and the code thay generates them so they use a plain-old datasource, but I don't really have the time to do that. It would definitely not be trivial. I'm pretty sure that my observation -- that footers can't be conditionally displayed depending on content overflow -- is correct. – Robert Bowen Mar 31 '16 at 16:17
  • You can not remove the band, but you can hide content in it, note you can use negative coordinates in footer band and with that hack you can be able to create a footer band that seems to be removed – Petter Friberg Mar 31 '16 at 16:22
  • Right, but again, using what ? If I have a Class with 10 Students that starts at the top of the column and ends before the end of the column, the footer should not be displayed. If I have another Class with 50 Students, it will inevitably be split between 2 or 3 columns, so the footer *should* be shown. But it's that 'if' that I don't know how to define ... – Robert Bowen Mar 31 '16 at 16:27
  • group it, a group count?, a count where you reset when class switches, but hey I do not know I need to see an example... – Petter Friberg Mar 31 '16 at 16:31
  • Yea, thought about that too. But it seems the is only printed when the group changes which in my case wouldn't help. In fact, I would need the opposite -- a footer that is displayed when the group does NOT change. :) I'll see if I can find the time to bang together some kind of example. I understand completely you can't do much more without an example ... – Robert Bowen Mar 31 '16 at 16:35

1 Answers1

0

In the end, the link that Petter Friburg posted solved my problem. I didn't think it did until I did a whole bunch of tests. First I tested with a simpler version of my reports, without all of the wrappers, etc. And it worked like a charm. But then I added another level of complexity to the reports. I had simplified them for this post but in reality they are more like

class.jrxml
  student.jrxml
    address.jrxml

So each class has n students, each student has n addresses. Once I put the pageFooter and lastPageFooter tags in the address.jrxml it worked fine.

My understanding was that if I put it in student.jrxml it should also work. But it didn't. However, it kind of makes sense to put it in address.jrxml, because if that info doesn't fit in the column that the student.jrxml content obviously doesn't all fit either, because address.jrxml is part of student.jrxml.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Robert Bowen
  • 487
  • 2
  • 13
  • 24