开发者

Printing Dynamic textfields with JasperReports

I am writing a software where a process set text to a JTextArea. The JTextArea has a previously set width and a height. If input text is too long 开发者_运维知识库font size is changed so the whole text will fit with in the boundaries of the JTextArea.

And then I want to print this JTextArea. Printed version should also have exact properties like my user interface. I am using JasperReports for this.

But the problem is I cant find a way to dynamically change font size in my generated report. Is there a way to do this? or please guide me to some good reference..

Thank you


One possible way I found is to create a couple of fields with different font sizes on top of each other and create a different print expression for each of them.

You could check the length of the string in the field and only display the field that is appropriate for the string length.

Something like below might do if set as the print expression of your field.

($F{myField}.length() > 20 && $F{myField}.length() < 100) 

The expression will be true if the String length is greater than 20 but less than 100.

If you create several these fields it should be appropriate to handle different lengths.


You can take a look at the DynamicJasper library. It allows you to create reports programmaticaly. Even more, you can use your current report as a template, and handle the textfield's font size through DynamicJasper.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜