preventing a word from being split w/linebreak

If I have a word in my template such as "account(s)", preceded by a field that results in variable-length text, sometimes that word will be rendered as:

account

(s)

 

Is there something I can put in the template to keep "account" and "(s)" together?

 

thanks. 

alask's picture
1
Joined: Nov 13 2008 - 11:36am
Last seen: 14 years 10 months ago

2 Answers:

Hi,

This is not possible, at least not in an easy way.

What I would try would be to calculate the character length of the content preceeding this word and if it is longer than a given limit, I would introduce a newline character to send the account(s) on the next line.

 

I hope this helps.
Teodor

 

teodord's picture
53198
Joined: Jun 30 2006 - 9:00am
Last seen: 1 day 1 hour ago

Teodor:

My name is Tony Chen. I am new to this Forum. Thanks so much for sponsoring this Forum. We encountered an issue where PDF exporter result in trailing word truncation for textfield with attribute isPrintWhenDetailOverflows="true" markup="html".

You recommend a solution by setting JRPdfExporterParameter.FORCE_LINEBREAK_POLICY, Boolean.TRUE. After this change, the truncation issue is resolved. However, lots of textfields with isPrintWhenDetailOverflows="true" wrap incorrectly and break up words like Account(s) broken into Account & (s), 6:00 am into 6 & :00 am, and i.e. into i & .e.

If we do not set JRPdfExporterParameter.FORCE_LINEBREAK_POLICY, Boolean.TRUE, we have word truncation. If we set JRPdfExporterParameter.FORCE_LINEBREAK_POLICY, Boolean.TRUE, we have incorrect wrapping. How can we resolve this?

We are using JDK 1.4.2, JasperReport 3.0.

Your help is really appreciated!

 

 

Code:
  Map fontMap = new HashMap();
  fontMap.put(new FontKey("Times New Roman", false, false), new PdfFont("times.ttf", "Cp1252", true));
 
  fontMap.put(new FontKey("Times New Roman", true, false), new PdfFont("timesbd.ttf", "Cp1252", true));
  fontMap.put(new FontKey("Times New Roman", false, true), new PdfFont("timesi.ttf", "Cp1252", true));
  fontMap.put(new FontKey("Times New Roman", true, true), new PdfFont("timesbi.ttf", "Cp1252", true));
 
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pdffilename);
exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap);
//force AWT&PDF using the same wrapp
//exporter.setParameter(JRPdfExporterParameter.FORCE_LINEBREAK_POLICY, Boolean.TRUE); 
</td></tr></tbody></table>
chent01's picture
Joined: Nov 14 2008 - 9:10am
Last seen: 14 years 10 months ago
Feedback