Manuela CodingPadawan
Manuela CodingPadawan

Reputation: 486

How to remove blank lines in case when WhenPrintExpression is false?

We are using JasperReports 6.6.

I use conditional expression to display certain parameters. The behaviour is as expected. However, when it is not printed, there is still blank line space. 

The fields are not touching each other, I took care. There are all isRemoveLineWhenBlank. Print when no expression is functionnal since the expression content is not displayed when the condition is not ok. The other elements are float type.

TRY

I tried solutions from other answers but do not correspond to my situation. I already tried them. I will explain more in details:

1) Removing blank entries from a Jasper report

For this one, I can't use frame. I already tried but unfortunately, I don't succeed to allow frame on several pages. Then, when my frame is above a certain treshold size, it goes directly onto another page. This is not what I expect.

About this issue, I asked a question but never get any answer: How to split a frame in several pages with jasper?

2) iReport: reposition elements after removeing line

Here, as I say at the beginning of my issue, I respect the requirements: - Textfield's value is empty - Textfield's "Remove line when blank" is checked - Textfield's Position type is setted to "Float" - Textfields are not touching each other

The only difference is that my values are not necessarily empty, such as the labels which are not related to any value. But there is the PrintWhenExpression condition on them.

3) iReport: How to hide line with text fields without data line contains different kind of data

How to remove frame with empty textFields?

JRXML SAMPLE with no parameters:

My problem is localized in the "Dispositions Facturation" content part. You can see in the source that the PrintWhenExpression is set to false for this content, and it does not appear and a blank line is left.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<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="revueDeCompte" pageWidth="595" pageHeight="842" columnWidth="511" leftMargin="42" rightMargin="42" topMargin="20" bottomMargin="20" uuid="e40ca3dd-a126-4201-ba2e-02fad2685c5a">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <parameter name="logo" class="Object" isForPrompting="false">
        <parameterDescription><![CDATA[Logo de la société]]></parameterDescription>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="50"/>
    </pageHeader>
    <detail>
        <band height="96" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="1" width="148" height="30" uuid="76987bd1-0e7e-44f6-a4ee-aa0783847905"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="14" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[REVUE DE COMPTE :]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="31" width="110" height="18" uuid="13afa98d-e049-41d9-a6de-4fcb461d589b"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Type : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="52" width="110" height="18" uuid="9a6e28b4-e6e5-4f68-8e3d-e163a5610d5e"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Responsable TVy :]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="73" width="110" height="18" uuid="05c1e5bc-093f-4a63-82fd-44faef979f62"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Groupe :]]></text>
            </staticText>
        </band>
        <band height="681">
            <staticText>
                <reportElement positionType="Float" x="10" y="43" width="140" height="18" uuid="d7d5535f-f538-4535-aaee-566ec690f97d"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Fichier descriptif :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="63" width="140" height="18" uuid="b0d26808-d829-49bb-ab7d-a46992abb6ff"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Contrat cadre :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="23" width="140" height="18" uuid="7fca0ca7-09e7-491e-9d7d-85bddb9bbefc"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Onglet généralité :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="2" width="200" height="18" uuid="a2a2787d-6685-442f-a630-08a0e9ee9a43"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Fiche société client dans MTV : ]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="83" width="140" height="18" uuid="dbe422df-12d8-42a9-aa3b-9d83df0f50f4"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Entités client :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="123" width="140" height="18" uuid="d9bb820b-402e-46e5-b624-6626be5bc81c"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Dispositions facturation :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="143" width="130" height="18" isRemoveLineWhenBlank="true" uuid="28be9fae-fd4e-4156-9938-71c2f5884f85">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[TVA :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="163" width="130" height="18" isRemoveLineWhenBlank="true" uuid="14923714-00fe-4263-bffd-d81cf11f0ecf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Numéro comptable :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="183" width="130" height="18" isRemoveLineWhenBlank="true" uuid="8343a99d-8da3-436e-8ee7-d9b9b47eb5b7">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Délai règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="203" width="130" height="18" isRemoveLineWhenBlank="true" uuid="01e27294-8e0e-4645-bfd6-38b7870fb7fb">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Conditions règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="223" width="130" height="18" isRemoveLineWhenBlank="true" uuid="1a59cabe-8998-4ca7-af0f-e67dd8ef7a67">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Type envoi facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="243" width="130" height="18" isRemoveLineWhenBlank="true" uuid="dc66bc38-2120-4b64-97cc-945e623bf2c2">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Adresse facturation :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="263" width="130" height="18" isRemoveLineWhenBlank="true" uuid="9ba512ca-ef68-44c5-8e19-58e57e2d980d">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails destinataires factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="283" width="130" height="18" isRemoveLineWhenBlank="true" uuid="c93554c7-e10e-4eaf-917b-c024ec204ddf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails copies factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="303" width="130" height="18" isRemoveLineWhenBlank="true" uuid="d0d6d749-a384-48b0-8649-25b544a8d6bf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Adresse envoi courrier :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="324" width="130" height="18" isRemoveLineWhenBlank="true" uuid="0b30dc0a-d562-4114-8f32-1b0a2dd26692">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Pièces factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="344" width="130" height="18" isRemoveLineWhenBlank="true" uuid="7ef51faa-5beb-4f00-ae3c-c80a9aeb6e84">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Titre facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="364" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cc4afcff-67c1-4426-8455-fe909f421492">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Commentaire tva facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="384" width="130" height="18" isRemoveLineWhenBlank="true" uuid="5cfb7ae1-3ef3-425e-b9ed-3e62187aefbb">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Référence contrat cadre :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="404" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cf7afd97-e009-4bf7-8a87-17c34198e8f8">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Référence fournisseur TV :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="423" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cbce1351-94c1-4fca-8382-bae70a80c551">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails relance commande :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="463" width="130" height="18" isRemoveLineWhenBlank="true" uuid="6456e941-a4a5-40ae-8929-b4b2b3c6e0ab">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails relance règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="504" width="200" height="18" uuid="50b8b039-07eb-4444-9149-d8e3b892196a"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Fiche Contacts clients dans MTV : ]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="525" width="140" height="18" isRemoveLineWhenBlank="true" uuid="b5c26cae-d87c-4e37-b309-e757495e56a7"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Contacts dirigeants :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="565" width="140" height="18" isRemoveLineWhenBlank="true" uuid="74b40a0b-fb21-4dc0-9945-352192be69f9"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Managers d'entité :]]></text>
            </staticText>
        </band>
    </detail>
    <pageFooter>
        <band height="71">
            <textField>
                <reportElement x="160" y="20" width="100" height="30" uuid="610924a5-4d05-4edc-bebf-a8abf14f274e"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement x="260" y="20" width="100" height="30" uuid="5acae58f-ec6d-4074-b37a-4a1f0853f30b"/>
                <textElement textAlignment="Left"/>
                <textFieldExpression><![CDATA[" sur " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
</jasperReport>

In this try, this is what I want:

PDF I WANT

And this is what I get:

PDF I GET

Could you help me to make those blank lines disappear, please?

Upvotes: 0

Views: 3043

Answers (1)

Alex K
Alex K

Reputation: 22857

What is wrong

You have a small vertical gap between every neighbours elements.

Gap between elements

Yes, it is small (only 3px), but it is exisits.

How to fix

I changed y position of all elements. I removed this gap:

y-position of element = (y-position + height) of previous element

Doing this trick I saved 98 px for "Managers d'entité :" label. Yes, not too much but as a result no more new page.

Difference

The modified design looks like this:

New design

The output result for this a little bit modified template is:

Preview at JSS

For now, in case removing element(s) - the all elements below will be pull out without any issues.

This is how the JasperReports engine works. You have to play using this rules.

Upvotes: 3

Related Questions