jbuberel Posted May 6, 2010 Share Posted May 6, 2010 In our JRXML templates, we display US city names. The text field uses a fixed font size (11pt) to render the text.However, there are times when we run into very long city names (ex: "Fredericksburg") that are too long to fit in the text box. So instead, I would like to use an expression for the size:<font size="11"/>would instead be:<font size="$F{city}.length() > 10 ? 9 : 11" />Or in other words: If the length of the city field is greater than 10 characters, use font size 9. Else, use font size 11.I am going to experiment with this later this evening, but thought I'd ask if others had run into this before and had come up with a good solution.Thanks,jason Link to comment Share on other sites More sharing options...
Teodor Danciu Posted May 6, 2010 Share Posted May 6, 2010 Hi, This is possible with markup text fields (formely known as styled text fields).See the /demo/samples/markup and /demo/samples/styledtext samples provided with the JR project. http://jasperreports.sourceforge.net/sample.reference/markup/index.html#markuphttp://jasperreports.sourceforge.net/sample.reference/styledtext/index.html#styledtext I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now