Ahmed Salem
Ahmed Salem

Reputation: 1757

How to Stretch Jasper Table Columns based on Content

In jasper report (iReport 4.5) I need to make all table fit it's content width, Image below show how columns contain spaces which not needed

I tried "Stretch Type" to be "Relative to tallest object" but not work

enter image description here

Upvotes: 1

Views: 5313

Answers (1)

Dave Jarvis
Dave Jarvis

Reputation: 31171

There are many possibilities for dynamic widths using PDF formats. All of these possibilities will likely involve developing custom software. It can be done, but it isn't trivial. Here are a few ways, though the column does not "stretch" per se -- the width of the column must be known before the report template is created.

It's possible to calculate the width of the column if you know the content and the font attributes (family, weight, size, etc.) in advance.

Dynamic Template

Since JRXML files have a straightforward format, it is possible to write a shell script, batch program, or application to generate .jrxml files. This allows complete control over page and column widths. The Java code will have to compile the .jrxml file before the corresponding .jasper file can be filled.

Dynamic Jasper

Use Dyanmic Jasper to create reports with dynamic widths.

Upvotes: 2

Related Questions