Force Jasper HTML report to wrap text by breaking mid word

独自空忆成欢 提交于 2021-02-07 06:10:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27290621/force-jasper-html-report-to-wrap-text-by-breaking-mid-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!