How to stretch text field relative to data width in Jasper reports

I have a text field followed by a static text field, and I'm trying to do 2 things with it:

  • Get the text field to stretch horizontally (do not wrap) when the text is longer than the width of the field and
  • Click the static text box right when the text box to the left of it is stretched

Both fields are contained in a frame.

I have both fields that are set as positionType = float, and the text field is set to stretchWithOverflow = true, which allows me to wrap text vertically but not stretch horizontally.

Is it possible to reach 1 and 2 above? If so, how?

+4
source share
2 answers

Instead of two text fields (dynamic and static) you can have 1 text field with the value $F{Field} + "statix text" . This will probably fix the problem. In addition, you can set the “width” and “stretch with overflow” properties to suit your requirements.

+9
source

Well, this is bad news! According to Jaspersoft documentation on stretch fields , it is not possible to stretch the width of a field:

“Typically, the stretching process refers only to adjusting the height. When stretching report elements, adjusting the width can also affect page width and increase unexpected errors at runtime (for example, truncated information can be printed on pages). That's why stretching an element so that its width remains unchanged, and its height is definitely increased to make room for all the information that needs to be displayed "(Jaspersoft documentation [v4.5.0], 2011)

However, a solution to the original problem can be found here thanks to @mdahlman

+1
source

Source: https://habr.com/ru/post/1392553/


All Articles