Error transferring text in pdf file

I have a problem with text wrapping in pdf format. For all formats, such as xls, rtf and pptx, the report works fine, but some text is wrapped in pdf, i.e. Some letters of the text, especially the last few letters, will be printed on the next line. I tried almost all the options in the properties for this text. The only way to reduce the effect is to change the pdf font name to roman time for this text. However, even this does not work in some cases.

The snippet contains a TextField problem:

 <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 really appreciate it if you share some solutions for this. Thanks...

Ps I get this problem when I create a report from Ireport 4.0.2

+4
source share
4 answers

First, use font extensions. Your problem is very likely because JasperReports (iText) does not use the font you want to use when creating the PDF. Font extensions allow this.

Secondly, it is possible that you are facing a problem that has been fixed. The JasperReports 4.1.1 change log includes the following:

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

+3
source

You can avoid this by adding a space to the text. I also use jasper4.0.2 and it worked for me.

+2
source

Some elements (TextField or StaticText) can increase its height, depending on the properties of the stretch type and stretch with overflow . But the width of an element cannot be changed without programming.

Quote from the iReport Ultimate Guide :

Stretch type - this attribute defines how to calculate the element height during printing; Three possible values: as follows: NoStretch . This is a predefined type of stretch, and it is that the height of the element must be the same. RelativeToBandHeight - the height of the element increases in proportion to the increase in the size of the strip; this is useful for vertical lines that mimic table borders. RelativeToTallestObject - The element changes its height according to the deformation of the nearest element: this option is also used with an element group, which is an element group mechanism not controlled by iReport

Stretch with overflow . When selected, this option allows the text field to adapt vertically to the content if this element is not enough to contain the entire text string.

You can use, for example, the ColumnBuilder class from the DynamicJasper API to set the column width.

You can also read this discussion .

0
source

For problems with text wrapping in pdf export in iReport 4.0.2 :

Convert your fonts to Jar, then add as an external banner, it will definitely work.

In the iReport Designer:

Step 1) Tool → Option → Fonts → Install Fonts

Step 2) Select this font → click on export as extension [do it as a JAR]

Step 3) Go to Classpath -> click on ADD Jar -> add your font banner -> OK

Now view the report.

0
source

Source: https://habr.com/ru/post/1379107/


All Articles