i have a title band. my report is landscape 595 by 842. i simply want the title band to take up a full page and be able to add text to the very bottom of that title page/band.
i have tried position fix relative to bottom. it still floats up. i have tried making the title band 559 high (with 36 top margin to make 595). that works except there is tons of white space and so if something on the title expands (dynamic data) the text at title page bottom breaks to second page.
Got it! Problem is that title band does not stretch, so fix relative to bottom does not work. Solution is to add a background band, height of report (minus margin). Then put page footer there, is will show on title and all other pages. Then add a blank page footer to save white space for the real footer in the background. done.
Why not use only the pageFooter and then if you only like it to display on first page use the printWhenExpression.
<pageFooter>
<band height="50">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue()==1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="dd4c229b-7453-4026-b01e-cfc325053335"/>
<textFieldExpression><![CDATA["You will only see me on first page"]]></textFieldExpression>
</textField>
</band>
</pageFooter>
Note the pageFooter will be present on every page (even if blank), this is the famous firstPageFooter request / tracker, but this seems not to be your case since you are already adding it later...
Related
I'm working on a report in Jasper for Java. I put the table header in the title band, the content in the details band and the summary part of table in the summary band (these are all different tables). The same Dataset is used in all three tables.
Here is the scheme of bands
However, when I print it to pdf (via Java REST service) this gap appears between tables. Picture
Tell me please how to remove it? Any ideas appreciated.
Stretch the row height to full title band.
Also adjust the height of the band using below code snippet:
<band height="<your_couple_of_lines_of_text_height>">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER} < 2]]></printWhenExpression>
the_conditional_header_content_here
</band>
I have requirement to hide the line after setting a property isPrintRepeatedValues="false" and values is not repeated but the getting line.and check the below image and highlighted with red color arrow.
That is shouldn't come and USA will come central. Can i achive this requirement if possible?
You can use subreport for all fields exclude first field.
First field and subreport placed into frame with borders.
For first field set properties:
stretchType="RelativeToBandHeight"
verticalAlignment="Middle"
First field haven't borders.
I try to border my bands in this way:
But I have a text field of my row detail with property isStretchWithOverflow="true"
In this way when I try to print my report, on the rows with overflowed text field, I've a discontinue on my border (white space instead draw line of frame).
Very simple.
I've added this property stretchType="RelativeToTallestObject" on my frame object.
So the line has not discontinuity.
My detail element is as follows:-
<detail>
<band height="22" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement uuid="a59a8d47-59cb-490e-953d-d4b1e2af52c0" x="0" y="0" width="191" height="20"/>
<box leftPadding="5" rightPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="ARIALUNI" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{key}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="09798815-2a54-42db-963a-3f443a5fc1c2" x="191" y="0" width="500" height="20"/>
<box leftPadding="5" rightPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="ARIALUNI" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
</band>
</detail>
If I set band height="30", then the value of second correctly overflows but at same time extra white space is visible for rows where there is no overflow. With band height="22", no extra whitespace and also no overflows (which is a requirement). So can the height of band be set dynamically so that height increases when overflow takes place, otherwise it (height) maintains a low value (without extra-space).
This already happens automatically. If a band contains content that stretches, it will also stretch to accommodate that content. Or, as the JasperReports Ultimate Guide puts it:
"When stretchable text fields are present on a report section, the height of the report section
itself is affected by the stretch."
This makes sense when you think about when the report is filled. Theoretically you could always pass longer and longer data, making the text field stretch further and further. If the band height had to be set manually to accommodate this, you would be forever updating the design.
So what's the solution? Easy: Design everything at the minimum height, set fields to stretch if they need to, and don't worry about the band height.
What about the white space?
The white space you're seeing is probably due to the way space in the design is preserved at the end of a band. With your example, the band height is 22 pixels, but the content only fills a height of 20 pixels, leaving a 2 pixel row of white space at the bottom of the band. When you increase the band height to 30 pixels, without increasing the size of the content (I'm assuming this is the case), you will have created 10 pixels of white space.
The white space you leave in you design will be included in the filled report, repeated for each instance of the band and still included if the content stretches. So after your text field stretches to be 30 pixels tall, the band will stretch to 40 pixels to preserve the 10 pixels of white space.
I've got the following problem with a JasperReports subreport that I've been trying to solve for the past couple of days with no success. Below is an image of what I'm trying to do.
I've got a subreport in one of my reports that is relatively simple. Its got a title band with a single text field (marked brown in the image) for the subreport title and a detail band with two items: a subreport (marked blue in the image) printing my line items and a text field (marked red in the image) printing the comments associated with the line items printed to the left of it. The line item subreport can print a variable number of line items (datasource backed by a bean collection). My customers requirement is that the comments field stretches and shows the text entered, but be limited by the height of the line item section (represented by the arrows on the image). I somehow need to prevent the comments from stretching beyond the line items and make them of equal height (there should be no green box in the image).
Does anyone have any tips how this could be (and can it at all be) achieved in JasperReports?
p.s.
We are currently compiling our reports with JR version 3.6
Put both the subreport and the text field into a frame. For the text field, set "Stretch with overflow" to false and "Stretch type" to "Relative to tallest object"
The text field will stretch relative to the tallest object in it's container. It's container is now the frame, so the "tallest object" can only be the subreport. Make sure the elements are the same height when you define them, otherwise they will grow at different rates.
JRXML sample:
<band height="50">
<frame>
<reportElement x="0" y="0" width="555" height="50"/>
<subreport>
<reportElement x="0" y="0" width="378" height="50"/>
...
</subreport>
<textField isStretchWithOverflow="false">
<reportElement stretchType="RelativeToTallestObject" x="378" y="0" width="177" height="50"/>
...
</textField>
</frame>
</band>