Jump to content
We've recently updated our Privacy Statement, available here ×

Extra line spacing in generated pdf


Recommended Posts


I am facing the  problem of extra line spacing when generating pdf.
I am using  jasperreports-5.6.0 jar.
When the text in textField is large then accommodates all text in single line and after that it leaves space.
I have attached the pdf for reference.


in jrxml I have 

<style name="RegularText">
        <conditionalStyle>
            <conditionExpression><![CDATA["text/plain".equals($P{CONTENT_TYPE})]]></conditionExpression>
            <style fontName="Courier New" fontSize="13"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA["application/pdf".equals($P{CONTENT_TYPE})&& $P{IS_BOLDED}]]></conditionExpression>
            <style fontName="Arial" fontSize="10" isBold="true"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA["application/pdf".equals($P{CONTENT_TYPE})&& !$P{IS_BOLDED}]]></conditionExpression>
            <style fontName="Arial" fontSize="10"/>
        </conditionalStyle>
    </style>

<band height="13" splitType="Stretch">
            <printWhenExpression><![CDATA[!"text/plain".equals($P{CONTENT_TYPE}) && $V{value}.length()>0 && $P{IS_BOLDED}]]></printWhenExpression>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="textField-3" style="RegularText" mode="Transparent" x="143" y="0" width="413" height="13" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="4f9d02e5-825b-487a-913b-bf6c21aa461d">
                    <printWhenExpression><![CDATA[!$P{BULLETS_WITH_PERIODS}]]></printWhenExpression>
                </reportElement>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Top" rotation="None">
                    <font isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{value}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement style="RegularText" x="128" y="0" width="13" height="13" forecolor="#FFAFAF" uuid="5ebabdae-bda0-42b4-98b5-5f7749797ff1"/>
                <textFieldExpression><![CDATA["\u2022"]]></textFieldExpression>
            </textField>
        </band>



However when i remove isBold=true from style it works fine.

Can anyone please help me with this?

wihtoutbox.pdf

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

In JasperReports Library 7.5.0 the isStretchWithOverflow attribute has been deprecated, and replaced with the textAdjust attribute.  These are helpful when your textField's dimensions might be too small for the amount of data that might come from your datasource.   The textAdjust attribute includes the original two behaviors and adds a third. 

Please use the StretchHeight option in the test field to avoid the text cut issue.

- StretchHeight: replicates the previous behavior you got from setting isStretchWithOverflow to true

https://jasperreports.sourceforge.net/schema.reference.html#textField

Link to comment
Share on other sites

Posted (edited)

Hi Swapnil Pawar
Thanks for your response.

I have certain limitation and i cant upgrade to 7.5.0 and in 5.6.0 it is not allowing to use textAdjust.
I am getting below exception.

org.xml.sax.SAXParseException; lineNumber: 183; columnNumber: 96; cvc-complex-type.3.2.2: Attribute 'textAdjust' is not allowed to appear in element 'textField'.

Can you please suggest something in 5.6.0.

Regards,
Zahid

Edited by zahid2948
Link to comment
Share on other sites

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...