The header of the report consists 10 elements it should look like this:
|1 2 3 4 5 6 7 8 9 10|
|--------------------|
In reality it look like this:
|1 2 8 9 10|
|---3 4 5 6 7 ------|
Is this something to do with the verticalAligment? I have set it to Bottom.
The snippet from my jrxml file:
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="39" isSplitAllowed="true" >
<rectangle>
<reportElement
x="0"
y="1"
width="780"
height="30"
backcolor="#999999"
key="rectangle-1"/>
<graphicElement stretchType="NoStretch"/>
</rectangle>
<staticText>
<reportElement
x="0"
y="0"
width="40"
height="30"
key="staticText-1"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Holder Id]]></text>
</staticText>
<staticText>
<reportElement
x="40"
y="0"
width="50"
height="30"
key="staticText-2"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Shell Id ]]></text>
</staticText>
<staticText>
<reportElement
x="100"
y="1"
width="50"
height="30"
key="staticText-3"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Product Id]]></text>
</staticText>
<staticText>
<reportElement
x="160"
y="1"
width="40"
height="30"
key="staticText-4"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[SPID]]></text>
</staticText>
<staticText>
<reportElement
x="200"
y="1"
width="40"
height="30"
key="staticText-5"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Loc-
ation]]></text>
</staticText>
<staticText>
<reportElement
x="300"
y="1"
width="50"
height="30"
key="staticText-6"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Date]]></text>
</staticText>
<staticText>
<reportElement
x="350"
y="1"
width="30"
height="30"
key="staticText-7"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Normal Fare]]></text>
</staticText>
<staticText>
<reportElement
x="380"
y="1"
width="30"
height="30"
key="staticText-8"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Actual Fare]]></text>
</staticText>
<staticText>
<reportElement
x="410"
y="1"
width="40"
height="30"
key="staticText-9"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Currency Code]]></text>
</staticText>
<staticText>
<reportElement
x="450"
y="1"
width="30"
height="30"
key="staticText-10"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Staff Id]]></text>
</staticText>
<staticText>
<reportElement
x="250"
y="1"
width="40"
height="30"
key="staticText-11"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Dest-
ination]]></text>
</staticText>
<staticText>
<reportElement
x="750"
y="0"
width="30"
height="30"
key="staticText-12"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[ISAM Seq.]]></text>
</staticText>
<staticText>
<reportElement
x="700"
y="0"
width="50"
height="30"
key="staticText-13"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[ISAM Id]]></text>
</staticText>
<staticText>
<reportElement
x="670"
y="0"
width="30"
height="30"
key="staticText-14"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Trans. Type]]></text>
</staticText>
<staticText>
<reportElement
x="630"
y="1"
width="40"
height="30"
key="staticText-15"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[CPICC]]></text>
</staticText>
<staticText>
<reportElement
x="510"
y="1"
width="30"
height="30"
key="staticText-16"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Conc. Auth]]></text>
</staticText>
<staticText>
<reportElement
x="480"
y="1"
width="30"
height="30"
key="staticText-17"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Suppl. Info.]]></text>
</staticText>
<staticText>
<reportElement
x="540"
y="1"
width="40"
height="30"
key="staticText-18"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Trans. Seq. No]]></text>
</staticText>
<staticText>
<reportElement
x="580"
y="1"
width="40"
height="30"
key="staticText-19"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Rem. Uses]]></text>
</staticText>
</band>
</columnHeader>
Without seeing your JRXML file, the best guess would be one (or combination) of two things:
You do not have the vertical alignment set to Bottom for the fields 1,2,8,9,10.
You do not have the same height set for 1,2,8,9,10.
In addition to those two, you do not have the tops set at the same Top value set for all the elements. Again this is all a best guess without being able to see your JRXML. If it is not one of those you will need to post it, so we can help.
I have tried the stretch type, position type, flot etc.... bottom, asTallest, all sort of thing, it seems nothing worked
what I did was
to change the height of the which around all me header ReportElements from 39 to 20
and each height from 30 to 15
increase some width, make sure they are wide enough
the height 15 kind of forced the texts to stay in one line, give them no space to float,
I feel its a kind of ugly fix, my instinct tells me it must not be the greatest solution, but it works and I need finish it by today. free to post answers, I will accept yours if it works, and much more elegant.
please see the Y Position. It is not same for all heading. you give Y position 0 for 1, 2, 8, 9, 10 and y=1 for remaing item. please make sure all position is same.
Related
This question already has answers here:
Stretch with overflow Detail band not working as expected
(2 answers)
Closed 2 years ago.
I have made a report In which I want to wrap words When the text is longer than the line But the result is the text has been entered below the line Causing all results to be out of line. How to......
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement stretchType="RelativeToTallestObject" x="259" y="2" width="48" height="17"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="AngsanaUPC" size="13" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{TRDATE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="312" y="2" width="113" height="17"/>
<textElement verticalAlignment="Middle">
<font fontName="AngsanaUPC" size="13" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{LOCATION}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="426" y="2" width="58" height="17"/>
<textElement verticalAlignment="Middle">
<font fontName="AngsanaUPC" size="14" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{SAVENAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="486" y="2" width="59" height="17"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="AngsanaUPC" size="13" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{SAVEDATE}]]></textFieldExpression>
</textField>
<line>
<reportElement x="10" y="18" width="535" height="1"/>
<graphicElement>
<pen lineWidth="0.25"/>
</graphicElement>
</line>
<textField>
<reportElement x="11" y="1" width="33" height="17"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="AngsanaUPC" size="13" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{SEQ}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="47" y="2" width="212" height="16"/>
<textElement verticalAlignment="Middle">
<font fontName="AngsanaUPC" size="13" pdfFontName="AngsanaUPC" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{COURSENAME}]]></textFieldExpression>
</textField>
</band>
</detail>
Example output for report:
Desired result:
Select all the elements in the band and set Stretch type = "Relative to Tallest Objest"
I'm currently working in a API that will generate reports (with JasperReports 6.12.2), in this case I have to print a large String in a text field, the problem is that I can't give the appropiate behaviour to this element to adjust the height to the String size.
I've been searching before to ask, and all that I've found was about the property isStretchWithOverflow="true", but isn't working for me because in my version this is deprecated and replaced with textAdjust="StretchHeight" so basically all the results finish with the same, the text is cutted by the text field.
Note: Also I have to say that this necessity of dynamism is because i need to paginate the report.
Element Text Field JRXML code:
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="190" width="555" height="321" isPrintWhenDetailOverflows="true"/>
<textFieldExpression><![CDATA[$P{text}]]></textFieldExpression>
</textField>
Complete Band Detail JRXML code:
<detail>
<band height="802" splitType="Stretch">
<textField>
<reportElement x="0" y="40" width="140" height="20" uuid="8e0ef27f-45c4-45f5-8c36-93e126db95db"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.codigo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="60" width="140" height="20" uuid="6cfe8e0b-0b7d-47f5-be4e-4c94d7f19fac"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.fecha}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="80" width="140" height="20" uuid="c8508fc6-3b17-4bcc-a207-2a9beff32263"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.enviado}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="100" width="140" height="20" uuid="5f7c732e-aeee-4896-bf11-dbd8f2c2b02f"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.asunto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="140" height="20" uuid="71f51ac1-63c5-4abb-909a-3f31b14e0e80"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.canal}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="140" width="140" height="20" uuid="00e9ac8d-c331-429d-944a-240e6abf2107"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.nombre}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="160" width="140" height="20" uuid="4b22fdfb-36a3-41da-86d1-a527ca67667d"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.texto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="40" width="405" height="20" uuid="bc346e06-c225-4451-bde7-67bde39d402e"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{codigo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="60" width="405" height="20" uuid="1d0ac2a4-fcb9-4ad3-9d9d-db440ae5cfb3"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse($P{fAlta}))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="80" width="405" height="20" uuid="d0189a13-4ded-45a1-82ad-5896a50f7fbf"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{mailPara}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="100" width="405" height="20" uuid="b0cfff7f-9230-4351-a59c-bf550fc4f0c2"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{asunto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="140" width="405" height="20" uuid="15f48c57-404d-47e2-94a9-26da75054aa9"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{operador}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="150" y="120" width="405" height="20" uuid="0926440c-f596-47a4-b7b4-674faa82b407"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<text><![CDATA[Operador ATC]]></text>
</staticText>
<textField>
<reportElement x="0" y="20" width="140" height="20" uuid="664930ad-64a1-44fc-9cdb-4ef34eb7cffa"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.idPeticionATC}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="20" width="405" height="20" uuid="d9303c25-1ea8-45ca-b4b7-984a0b95d4ee"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{idPeticionATC}]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="190" width="555" height="321" isPrintWhenDetailOverflows="true" uuid="0e59dd92-0a62-453a-9167-6a9d5b43ff54"/>
<textFieldExpression><![CDATA[$P{text}]]></textFieldExpression>
</textField>
</band>
After a while trying to solve this issue I've found the problem.
Recently Jasper Reports upgraded the version to v6.11 (Published: 2019-Dec-12), in this version Jaspersoft® Studio changed the property isstretchwithoverflow is replaced by textAdjust, so the problem was related with the version, and I realized that my Jasper reports library was in an older version v6.2, where the propertie textAdjust doesn't even exist.
So if anyone else is having this problem, please, check your library version, if it's under version 6.11 and your editor plugin is version 6.11 or higher, you will not be able to overflow texts and paginate properly.
The property isStretchWithOverflow was replaced in the JasperReports Library 6.10.0 by the textAdjust property. So to achieve the dynamic stretching effect, you need to set textAdjust="StretchHeight".
If you set your compatibility settings in Jaspersoft Studio ("Window > Preferences > Jaspersoft Studio > Compatibility") accordingly, it will automatically change the property to the compatible version, i.e. textAdjust="StretchHeight" will automatically be exchanged for isStretchWithOverflow="true" when you select a version <= JasperReports 6.5.1.
Here is my JRXML On the second page I created a table using the nested list. In Preview in Jaspersoft Studio everything looks good, but after generating PDF on the page where my nested list is, an empty page is added. I have no idea how I can fix this problem.
I tried:
Remove Line When Blank - for lists and fields.
When No Data Type - all options tried and tested.
I have a problem with generating an additional blank page in PDF. Our company system does not support generating reports from subreports to multiple pages. As a workaround, a 43 page printout was created and each page is divided by "Page Break". This works well. My data source is an XML file.
I've tried to solve previously given here in similar problems but it doesn't help.
I don't want to generate this empty page.
Part of nested list code:
<componentElement>
<reportElement x="0" y="240" width="555" height="40" uuid="5a5114e6-f143-4e73-9a70-6aa3285b4d31">
</reportElement>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="OrderItems" uuid="a5783264-74e9-43b2-8312-84e805170f06">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/wstxns1:XML/wstxns1:p7_Object/wstxns1:productOrder/wstxns1:items")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="40" width="555">
<textField>
<reportElement style="Table_TD" x="0" y="0" width="185" height="20" uuid="9f67e274-92bc-4a21-8403-d60b4115c5c3">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{prospect/name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="185" y="0" width="185" height="20" uuid="262d8477-4cdc-47dc-b746-b38793e05757">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[($F{totalReccuringChargeAmount}!=null)?(new BigDecimal($F{totalReccuringChargeAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString() + " " + $F{totalReccuringChargecurrency}:""]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="370" y="0" width="185" height="20" uuid="a9aad9d3-9269-427e-b0e7-032f582c44e7">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{commitmentPeriod[Level0]}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="20" width="555" height="20" isRemoveLineWhenBlank="true" uuid="96c06463-aaa8-4ee9-80be-0110bbc8258c">
</reportElement>
<jr:list printOrder="Vertical">
<datasetRun subDataset="OrderItems" uuid="100d9171-37f5-45fc-b7b8-affe80e508af">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("//wstxns1:items[wstxns1:itemId = '"+$F{itemId}+"']/wstxns1:configuration/wstxns1:prospect/wstxns1:children/wstxns1:items")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="20" width="555">
<textField>
<reportElement style="Table_TD" x="0" y="0" width="185" height="20" uuid="1e3d8870-3a1f-4cd2-923d-ac1547d5805f">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA["--"+$F{prospect/name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="185" y="0" width="185" height="20" uuid="8dee85a5-406b-4a81-ab42-1d29ade1ceab">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA[($F{totalReccuringChargeAmount}!=null)?(new BigDecimal($F{totalReccuringChargeAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString() + " " + $F{totalReccuringChargecurrency}:""]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="370" y="0" width="185" height="20" uuid="80044161-2cc9-461d-bb6b-4b7426d9479c">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{commitmentPeriod[Level1]}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:listContents>
</jr:list>
</componentElement>
<textField>
<reportElement style="Table_TH" positionType="Float" x="185" y="280" width="185" height="30" backcolor="#D9D9D9" uuid="9e550a00-d376-4f3d-859e-9f3ebd875b76">
</reportElement>
<box>
<pen lineWidth="0.5"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Top">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[($F{mainOrderTotalAmount}!=null)?(new BigDecimal($F{mainOrderTotalAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString()+" "+$F{mainOrderCurrency}:" "]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Table_TH" positionType="Float" x="0" y="280" width="185" height="30" backcolor="#D9D9D9" uuid="aa918c59-db11-49ad-8ab1-1e296b8e8b08">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Total: ]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="0" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="5e3cea42-8937-4876-9ef3-4fef54ae66db">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Package name]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="185" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="a76bf537-65a0-400f-a75a-b0f03bd88796">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Monthly charge]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="370" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="6893b476-bcc2-42ab-8078-364f13b6fcf6">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Contract period]]></text>
</staticText>
<staticText>
<reportElement x="0" y="750" width="555" height="40" uuid="eb235aed-5c5e-4ef3-b9ab-f776e5307aa9">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9"/>
</textElement>
<text><![CDATA[O749504]]></text>
</staticText>
</band>
Any ideas guys? Maybe you need more details?
Maybe this will help you:
Set the split Typ of the detail band to Stretch:
splitType="Stretch"
best wishes
We had a similar problem. If the a list was the last item in the page in same cases a blank page was added.
When we added the whole list to a new band the empty page disappeared.
The objective of my study is to print a table that I have on SQL Server, the data connecting is done, the interface and the printing are done too.
The problem occurs when I print the PDf of the report because I want to print a number of rows per page but it only prints me one row of the table per page, so if my table has 205 rows, it prints 205 pages, haha, kinda weird.
This is my first time using JasperReports. Here is my jrxml file.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listadoCensosDiarios" language="groovy" printOrder="Horizontal" pageWidth="2400" pageHeight="1000" orientation="Landscape" columnWidth="2360" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d8233986-9ca6-4eb9-852a-0c0bf896d505">
<parameter name="ruta" class="java.lang.String"/>
<field name="CodigoCama" class="java.lang.String"/>
<field name="Documento" class="java.lang.String"/>
<field name="Nombre" class="java.lang.String"/>
<field name="Edad" class="java.lang.String"/>
<field name="Empresa" class="java.lang.String"/>
<field name="Especialista" class="java.lang.String"/>
<field name="Diagnostico" class="java.lang.String"/>
<field name="FechaIngreso" class="java.lang.String"/>
<field name="Dias" class="java.lang.String"/>
<field name="Dieta" class="java.lang.String"/>
<field name="Observaciones" class="java.lang.String"/>
<field name="Registrado" class="java.lang.String"/>
<field name="FechaRegistro" class="java.lang.String"/>
<variable name="totalPaginas" class="java.lang.Integer" resetType="Page" incrementType="Report" calculation="Count"/>
<title>
<band height="58" splitType="Stretch">
<rectangle>
<reportElement uuid="df0fa9dd-b7f1-4800-b1bf-f40de1bc7263" x="64" y="1" width="1801" height="50" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="f773ff3c-e683-41f4-8f16-7d8c66d54562" mode="Opaque" x="64" y="2" width="1801" height="48" backcolor="#E0E0E0"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="20" isBold="true"/>
</textElement>
<text><![CDATA[CENSO DIARIO]]></text>
</staticText>
<rectangle>
<reportElement uuid="07b7d0a3-0b20-4649-a1b2-0045ca40372e" x="1" y="1" width="63" height="50" backcolor="#E0E0E0"/>
</rectangle>
<rectangle>
<reportElement uuid="e076ba71-8906-4238-a19d-f75077425de6" x="1865" y="1" width="134" height="50" backcolor="#E2DEDE"/>
</rectangle>
<image hAlign="Center" vAlign="Middle">
<reportElement uuid="e0c8b5d2-3f68-4895-adea-e98d58a2ea3e" x="1" y="2" width="63" height="47"/>
<imageExpression><![CDATA[$P{ruta}+"//img//LOGO1.png"]]></imageExpression>
</image>
<image hAlign="Center" vAlign="Middle">
<reportElement uuid="ce929fc5-57d6-4e20-b30c-9893f34edf61" x="1901" y="3" width="58" height="46"/>
<imageExpression><![CDATA[$P{ruta}+"//img//100calidad.jpg"]]></imageExpression>
</image>
</band>
</title>
<pageHeader>
<band height="24" splitType="Stretch">
<rectangle>
<reportElement uuid="b28a6cd6-7bb8-4332-a443-795537750291" x="0" y="8" width="1629" height="16" backcolor="#D3ECC7"/>
</rectangle>
<rectangle>
<reportElement uuid="da28e036-684a-4921-a42a-4afab1ff613a" x="1629" y="8" width="370" height="16" backcolor="#D3ECC7"/>
</rectangle>
<staticText>
<reportElement uuid="4ec9e82c-884b-49ea-9d84-41ef79374f2d" mode="Opaque" x="1632" y="10" width="360" height="14" backcolor="#D3ECC7"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="11" isBold="true"/>
</textElement>
<text><![CDATA[Información del Empleado]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<rectangle>
<reportElement uuid="0ed0631b-b8b3-4544-984a-6a8b152405a4" x="145" y="1" width="169" height="22" backcolor="#E0E0E0"/>
</rectangle>
<rectangle>
<reportElement uuid="5d9afa11-5f66-4c24-a689-790b6bbbfee8" x="0" y="1" width="52" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="d3cbfe71-89c2-40f4-83be-c388d60d1f57" mode="Transparent" x="10" y="0" width="39" height="22" backcolor="#E0E0E0"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Cama]]></text>
</staticText>
<rectangle>
<reportElement uuid="6e7ec76b-c44c-4ae1-8b14-868e9f596876" x="314" y="1" width="35" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="afc00f8f-d646-48be-b883-11beb5e4e5b3" x="318" y="1" width="25" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Edad]]></text>
</staticText>
<rectangle>
<reportElement uuid="065d81fe-b21e-4982-9843-c874f499a969" x="349" y="1" width="150" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="1215c9ac-9bc5-428d-9456-4c9c0ce81129" x="351" y="1" width="145" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Empresa]]></text>
</staticText>
<rectangle>
<reportElement uuid="9066f537-b0d4-4a43-b544-14704b4fc207" x="499" y="1" width="150" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="6ba919d0-8dc8-421e-890d-4d9e9bcdf639" x="501" y="1" width="146" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Especialista]]></text>
</staticText>
<rectangle>
<reportElement uuid="efeb1184-587c-43ce-bca3-3e6b25f10ea6" x="649" y="1" width="206" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="bc197cfe-a855-4da3-b25e-2d602e16e5c5" x="670" y="1" width="164" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Diagnostico]]></text>
</staticText>
<rectangle>
<reportElement uuid="b9dadc2e-8f0d-481d-a82d-f6f47263ef18" x="855" y="1" width="209" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="7c51754f-552c-445e-b7f4-668375f96f3b" x="868" y="1" width="183" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Fecha Ingreso Paciente]]></text>
</staticText>
<rectangle>
<reportElement uuid="efe37924-5b8b-46bb-b7ab-c35ec15f16f7" x="1173" y="1" width="156" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="4360b926-3429-4bcf-bf76-28c6ed3af80f" x="1219" y="1" width="65" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Dieta]]></text>
</staticText>
<rectangle>
<reportElement uuid="53b0b7be-341c-4d88-9d06-e9ce66f2ba38" x="1329" y="1" width="300" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="739a0a28-415c-4f19-97e7-0eb4d1967f0c" x="1346" y="1" width="269" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Observaciones]]></text>
</staticText>
<rectangle>
<reportElement uuid="5c0eb8ea-abbb-430f-8faf-bdc507ccdc43" x="1064" y="1" width="109" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="f620ed1e-a0a1-448f-a9cd-13b0824dda53" x="1064" y="1" width="98" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Dias Estancia]]></text>
</staticText>
<rectangle>
<reportElement uuid="f0ac1173-7313-46cb-bf0c-072abc746810" x="1629" y="1" width="250" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="f0650ba4-1a18-4ff8-b514-928fad9c0e47" x="1629" y="1" width="250" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Registrado Por]]></text>
</staticText>
<rectangle>
<reportElement uuid="ea2a4a77-fe25-4b62-8730-b04158cc4f43" x="1879" y="1" width="120" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="051cd84a-f45a-43ae-8e50-476a1723acdd" x="1879" y="1" width="120" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Fecha Registro]]></text>
</staticText>
<rectangle>
<reportElement uuid="146c7aa0-b3cd-496d-a9c7-49b74c37bd64" x="52" y="1" width="93" height="22" backcolor="#E0E0E0"/>
</rectangle>
<staticText>
<reportElement uuid="f657cfd7-da85-4e30-86ec-720183dbd38b" mode="Transparent" x="52" y="1" width="93" height="22" backcolor="#E0E0E0"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Documento]]></text>
</staticText>
<staticText>
<reportElement uuid="64287559-c995-45ba-b97f-dbfbecf62eab" mode="Transparent" x="145" y="2" width="169" height="21" backcolor="#E0E0E0"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Nombre(s) y Apellidos]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="626" splitType="Stretch">
<rectangle>
<reportElement uuid="ce513dc9-595a-4018-9b60-4184a87400cf" x="52" y="0" width="93" height="59"/>
</rectangle>
<rectangle>
<reportElement uuid="633a32fe-76d0-478c-a2e8-ef73630b698d" x="0" y="0" width="52" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="d1b97bd4-4e00-4aae-a0eb-d9532314933f" x="3" y="0" width="46" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{CodigoCama}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="58f022c4-755c-4341-9de7-152dbb01092b" x="145" y="0" width="169" height="59"/>
</rectangle>
<rectangle>
<reportElement uuid="9236e426-7562-40b9-8c87-02a31d29dacf" x="314" y="0" width="35" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="d77071b7-c1cc-40e8-ab57-92ad08278390" x="316" y="0" width="29" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Edad}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="76fa21b9-c41d-46bc-8c50-dee329b8c61c" x="349" y="0" width="150" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="81c4e8ba-6de5-471d-b8ca-3e9984105a99" x="354" y="0" width="140" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Empresa}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="836b0a1d-4268-4668-a63e-4df1b4834662" x="499" y="0" width="150" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="e0ee8d88-5ef1-4e7e-b534-c5cef786c942" x="505" y="0" width="140" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Especialista}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="49535787-c02d-4d34-9b83-ed192e0fb086" x="855" y="0" width="209" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="0a4641d9-76f8-4081-ba53-7d68e9934176" x="865" y="0" width="190" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{FechaIngreso}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="e4187b85-1c21-4041-8e0e-2c1a6f02cb72" x="1173" y="0" width="156" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="7883fd8a-e3f2-4930-8ec0-37fdb76f4fa4" x="1184" y="0" width="132" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Dieta}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="1a80ef21-1caa-46c2-a1ff-69a810997625" x="1329" y="0" width="300" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="cb697e3d-c8e0-4c98-a588-1eb92008d1f5" x="1345" y="0" width="269" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Observaciones}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="6e960357-27ac-4411-b0ab-1dc6c2bc101b" x="1064" y="0" width="109" height="59"/>
</rectangle>
<rectangle>
<reportElement uuid="3eca5ca2-a90b-4c1c-96d4-2ff47b699044" x="1879" y="0" width="120" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="548dcabc-6708-4a4b-902a-7fd7cc30f26c" x="1897" y="0" width="93" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{FechaRegistro}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="2cc8851f-d3b4-44cf-a97c-4ad7544765b5" x="59" y="0" width="79" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Documento}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="641978c2-69fc-45f3-a96c-25a53aa138b5" x="1629" y="0" width="250" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="66b12f81-615c-4bb7-8c18-3ce2f0e877d6" x="1635" y="0" width="236" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Registrado}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="0a4641d9-76f8-4081-ba53-7d68e9934176" x="1069" y="1" width="98" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Dias}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="8e458e73-d0fb-4707-b4b8-dd34642725af" x="151" y="1" width="155" height="59"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Nombre}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement uuid="e021e007-7a56-4ebe-a617-ab39f21dbb32" x="649" y="0" width="206" height="59"/>
</rectangle>
<textField isBlankWhenNull="true">
<reportElement uuid="61d0b9e9-f314-44a3-8aa4-ead1d3e726b6" x="659" y="0" width="185" height="58"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{Diagnostico}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="140" splitType="Stretch"/>
</pageFooter>
</jasperReport>
I tried with a page break but I got the same result.
Your detail band is too tall. Set its height to match the tallest element in the band, that is 59 pixels.
Requirement:
If firstName and lastName is non empty. Show this at x=125, y=3 coordinates.
And show address down to it at x="125" y="26" coordinate. This is working fine.
Problem: If firstName/lastName are empty, Then we need to move the address element up and show it at x=125, y=3 coordinate itself.
This is where I am stuck. Please help me.
Please refer my jrxml file below:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="125" y="3" width="264" height="23"
isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="125" y="26" width="264"
height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21"
isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>
You have already set the isRemoveLineWhenBlank attribute, which will remove the empty space left by the textField. However, JasperReports cannot collapse vertical space unless that space is completely clear. If there is another element occupying the same line (in your case the staticText element), the empty space will be preserved. This is a bit like playing Tetris in reverse; You have to get rid of all of the blocks before the line will disappear.
Putting report elements into frames modifies this behaviour slightly. It is only the width of the parent frame that needs to be clear, instead of the width of the whole report. Therefore, by putting your name and address fields into a separate frame, the space occupied by the name field can collapse despite being aligned horizontally with the static text. I have modified your code snippet to demonstrate this:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<frame>
<reportElement x="126" y="0" width="264" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="0" y="3" width="264" height="23" isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="0" y="26" width="264" height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</frame>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>