Jump to content
We've recently updated our Privacy Statement, available here ×

Setting text to truncate


nockdg
Go to solution Solved by Friendly User,

Recommended Posts

Hi,

 

Is there a way to automatically truncate text to fit the textfield?

 

I have a textField that allows space for 2 lines, but if the supplied text is long enough for 3 lines then nothing is printed in the textField.

I could use FontMetrics to determine how many characters would fit and then substring the data but was hoping there might be a way to do this automatically in Jasper.

 

Thanks,

Dave

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

There is a property that you can set at the global, report level or text element level. The default is false though.

net.sf.jasperreports.print.keep.full.text

Property used to determine whether the fill process must preserve the original text for text elements that are not able to fit their entire contents. When this property is set, the engine saves the original text in the JRPrintText print text object, along with the index at which the text is to be truncated by the print object.

 

 

Link to comment
Share on other sites

  • Solution

The text itself won't truncate, the engine will try to put whole text into the field. If you've allowed field to stretch with overflow or not will mean it will stretch the field to try to display it all. If not it'll just display as much as field dimensions allow. So if you want to truly truncate the large string using an expression is a good way to go.

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...