[#8066] - Word wrapping issue with special characters

Category:
Bug report
Priority:
High
Status:
Feedback Requested
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

Hi Team,

We are generating a PDF file using templates created in iReport designer. We are passing some dynamic text from java code to be printed in PDF. For each field we have defined some width.

The word wrapping works well in case of normal characters and also few special characters expect ! % ( ) - [ ] ; : " , . ?. When the last word exceeds the max length, the word is breaking at the special character and going into the next line.

Example: contribution(s), the word is breaking at ( and it is printed as contribution in line1 and (s) in line2. For this field the length is 115 and ( is the 116th character, so it broke at the ( and went onto newline. This is happening only with the character mentioned above.

Please let us know if this is a bug or is it considering these characters as soft returns? How the word processing works in Jasper reports.

Also please let us know if more information is required.

Regards,
Srikanth.

v4.7.1
srikanth8071's picture
Joined: Jun 27 2016 - 4:14am
Last seen: 3 years 7 months ago

16 Comments:

#1

iReport is no longer maintained. I suggest switching to Jaspersoft Studio and setting the net.sf.jasperreports.export.pdf.force.linebreak.policy property to true. (There's probably a way to do that in iReport as well, but I don't know the details.)

Regards,
Lucian

#2

Hi,

Yes we have tried setting net.sf.jasperreports.export.pdf.force.linebreak.policy property to true in iReport but this of no use. Please note word wrapping is working well with all the characters failing with the characters ! % ( ) - [ ] ; : " , . ?

This is very rare scenario and I doubt this can be fixed using line break policy even with Jasper studio. The issue must be existing with in Jasper studio also.

I feel this is some thing to do with the word processing in Jasper reports. Please let me know if my understanding is wrong.

Thanks & Regards,
Srikanth.

#3

Hi,

I even tried with Jasper studio 5.6.2 version, it is still printing (s) in new line.

Regards,
Srikanth.

#4

We'll need a test case (self contained JRXML) to reproduce the error.

Thank you,
Lucian

#5
  • Status:New» Feedback Requested
  • Assigned:nobody» lucianc
#6

Hi Lucian,

We will send you the JRXML in some time, for now attaching the screenshots of the issue.

Regards,
Srikanth.

AttachmentSize
Image icon jasperreports_wordwrap_2.jpg109.06 KB
#7

The screenshots shows how word break is happening for few special characters.

AttachmentSize
Image icon jasperreports_wordwrap_1.jpg155.55 KB
#8

Hi Lucian,

Attaching the JRXML with issue reproducible. I have placed here the static text, but the text is dynamic in my project. Attached the screenshots already.

Regards,
Srikanth.

AttachmentSize
Binary Data jasper_wrap.jrxml3.52 KB
#9

Hi Lucian,

Please let me know if anything else is required from my end.

Regards,
Srikanth.

#10

Could you explain how the report works for you, and how you expect it to work?

Regards,
Lucian

#11

Hi Lucian,

We have a java application from this java application we send data/text to Jasper reports to print the data in a PDF file. This particular report file will be given to my client's customer.

Jasper reports is printing the data fine, but only in case of special characters mentioned above it breaks the word. We expect the word wrapping in Jasper reports to work as is in Microsoft word.

Please let us know if you need more details.

Regards,
Srikanth.

#12

JasperReports uses java.text.BreakIterator.getLineInstance to determine where line breaks can occur within texts. The Sun/Oracle implementation of BreakIterator says that in a text like "their contribution(s) to the achievment", a line break can occur before the left parenthesis "(".

I tried ICU4J's BreakIterator, and it doesn't return the left parenthesis as a possible line break position. So one option would be to adopt ICU4J in JasperReports as a replacement for java.text.BreakIterator. I don't know whether ICU4J's BreakIterator work exactly like Microsoft Word, in this case at least I suppose it does.

Regards,
Lucian

#13

Hi Lucian,

Thanks for the update.

Can you please tell me how to use ICU4J's in jasper reports.

Regards,
Srikanth.

#14

It's not something that you can do from the outside, it needs to be changed in the JasperReports codebase.

#15

That cannot be done by us? How to go about it? Can you provide me the jasperreport jar file with this change?

Regards,
Srikanth.

#16

I don't have the actual changes, just an idea of a possible solution.

JasperReports is open source, therefore if you're willing you can get the sources and try to make the changes yourselves.

Regards,
Lucian

Feedback
randomness