Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Jasper HTML report to wrap text by breaking mid word

I have a Jasper report created in Jaspersoft Studio which is used to generate an HTML report. It has a width of 550px. One of the data fields contains URLs, and some of these can be very long, for example:

http://www.example.com/example?q=wifjaiojwefijawefwkopkfeomikwmfimvwkemmcwoemcomwclewccoepcopwijefijajowkopfkwoekfokwofsdvwefjijwie&fwjiejfiwjiejfiwjef&fwewfwef

The problem I am having is that the generated report does not break the URLs mid word, i.e. in the middle of the characters in the query string, so the text field is stretched rather than being fixed at 550px. The wrapping takes place when the ampersand is reached, whereas I want it to just wrap at whatever part of the string reaches the set width.

I have tried the following properties on both the field and the report:

  • net.sf.jasperreports.text.truncate.at.char = true

  • net.sf.jasperreports.print.keep.full.text = false

I have tried the following property on the report:

  • net.sf.jasperreports.export.html.wrap.break.word = true

The output was the same with all the combinations of these that I tried.

The same report is also used to generate a PDF report. The URLs in the PDF report wrap in the way I require, so it is just the HTML output that wraps differently.

I am using Jaspersoft Studio 5.6.2. The reports are run using JasperStarter 2.2.

Does anybody know how to get the HTML output to wrap in the required way?

like image 350
Owen Pauling Avatar asked Dec 04 '14 09:12

Owen Pauling


1 Answers

From JasperReport configuration reference, it seams you have to set

net.sf.jasperreports.text.save.line.breaks = true

so the HTML exporter explicitly add line break to the report.

like image 84
mpiffault Avatar answered Sep 24 '22 11:09

mpiffault