Jump to content
Changes to the Jaspersoft community edition download ×

preventing a word from being split w/linebreak


alask

Recommended Posts

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. 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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

 

Link to comment
Share on other sites

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); 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...