Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
929 views
in Technique[技术] by (71.8m points)

jasper reports - Text wrapping issue in generated pdf file

I have an issue related to wrapping of text in pdf format. For all the formats like xls,rtf, and pptx the report works fine,however in pdf some text gets wrapped i.e. some letters of the text especially the last few letters gets printed in the next line. I have tried almost all the options in the properties for that text. The only way I could reduce the effect was by changing the pdf font name to times roman for those text. However even this does not work in some case.

The snippet contains problem TextField:

<textField  isBlankWhenNull="true">
    <reportElement positionType="Float" x="560" y="0" width="60" height="20"/>
    <box leftPadding="2">
        <pen lineWidth="0.5"/>
        <topPen lineWidth="0.5"/>
        <leftPen lineWidth="0.5"/>
        <bottomPen lineWidth="0.5"/>
        <rightPen lineWidth="0.5"/>
    </box>
    <textElement>
        <font fontName="Arial Unicode MS"  isPdfEmbedded="false"/>
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA[$F{CustState}]]>
    </textFieldExpression>
</textField>

I would be very grateful if you share some solution for this. Thanks...

P.s I get this issue when i generate the report from Ireport 4.0.2

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First, use Font Extensions. Your issue is very likely because JasperReports (iText) isn't using the font that you want it to be using when generating the PDF. Font Extensions solve this.

Second, it's possible that you're encountering an issue that got fixed. The JasperReports 4.1.1 Change Log includes this:

the net.sf.jasperreports.export.pdf.force.linebreak.policy configuration property is now deprecated as the PDF text rendering code was refactored so that text is rendered exactly like in AWT


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...