iReport: how to hard fix a detail band's height, independent of it's content - jasper-reports

I use iReport and I try to fix a detail band's height independently of its content. My problem is that if one of my text fields has more than one line, the band "grows" and because of this I get a second page.
So is there any possibility to hard fix the height of a detail band?

Try setting the stretch type for the text field to "No Stretch" and the split type (see the properties menu) for the detail band to "Prevent".

Since we could not find any direct options, We are doing this in an indirect method, having PLSQL Procedure for data fetching, different sub-datasets are used for filling fixed height detail areas, so each fixed datasets are filled with max.rows which it can accomodate (within sub procedures). Hope it helps someone.

Related

iReport - How to prevent texfield go to next page

I need help!
When Textfield Text is too big and does not fit all the content on the page, it is automatically moved to the next page, can anyone help?
The result is the following:
The structure of the report is as follows:
structure of the report
The expected result would be to completely fill the first page, and then break to next.
You can manage your detail band selecting it and change the property Split type as the following image:
The meanings of three options:
STRETCH:
The band is allowed to split, but never within its declared height. This means the band splits only when its content stretches.
PREVENT:
Prevents the band from splitting on first break attempt. On subsequent pages/columns, the band is allowed to split, to avoid infinite loops.
IMMEDIATE:
The band is allowed to split anywhere, as early as needed, but not before at least one element being printed on the current page/column.
You can see here

stretch a textField to a max height in jasper reports

I think this is more of a general issue. I would like to use a textfield that gets dynamic data and doesn't stretch more than a given max height. For instance, I have a textfield that, if it gets text that fits in one line, the textfield will be one line height, and i have other elements under it, that will move up with float positioning. Or, if I want a 3 line max height and if the text exceeds that space, then the rest will be trimmed.
I don't want to use java expressions to trim that text, as it is not always accurate. I am new to jasper and I am trying to know if there is any way to do this. I did a lot of searches, but maybe there is something that i missed, and i hope someone can help me. Thank you
I managed to solve this by extending net.sf.jasperreports.engine.fill.TextMeasurer and overriding initialize() method; also I had to extend net.sf.jasperreports.engine.util.AbstractTextMeasurerFactory and override the createMeasurer() method.
Now, whenever I want to have max # of lines, with no overflow, I add a property to that text field (e.g. maxLines) which is being passed to my custom TextMeasurerFactory. I hope this helped you.
We had a similar problem at work with JASPER Reports 4.5, where we had an invoice with a header and a table. We wanted the header to have dynamic height based on the lengths of certain fields (like address, partner name, etc,), but not more than a critical limit, otherwise the header will push the table and thus making a mess by splitting it across multiple pages. Also, the invoice shouldn't exceed 1 page.
We eventually had to move the header in the background section, where we also put a background for the table consisting of vertical lines (so it will extend to the end of an A4 page) and a white opaque square.
This way, if the header exceeds the max height it will go underneath the table's background, cropping the text. This was the desired effect we were looking for.
Sounds crazy, but it worked ...

How to stretch text field on multiple pages in Jasper Reports?

Scenario:
I have a jasper report with multiple text fields inside a detail band. Each text field has the properties:
Position: Float
Stretch Type: Relative to tallest object
Print When Detail Overflows: False
Stretch With Overflow: True
The details band has the property:
SplitType: Stretch
Current Result:
When one of the text fields is taller than the page and extends to a next page, all other text fields stretch to the end of the page.
Problem:
I want all text fields to be able to stretch on the next page as well. If I use the property 'Print When Detail Overflows: True' then this causes the text fields to be 'reprinted' with data duplicated. That is not my intention. I want to be able to stretch the text field to more than one page.
Thank you!
I also have same problem and after playing whole day did not figure out anything :-(.
My workaround was to set whole band to "Prevent" split type. It is not solution. Only trying to not have text fields 'reprinted' with data duplicated.
You can try setting to the field's Stretch Type to Relative to Band Height. If that didn't work, just play with those properties. I believe you can accomplish it by playing with the properties you mentioned.

Default Crystal Text Field Height

In Crystal Reports 2011 when I create a new text field and add it in design view the height is 0.13. Other instances of Crystal I've seen always create these fields at a height of 0.16. How do I set my instance of Crystal to create fields at this height?
you have to change the hight or width your self, and if you want to change more than one textboxes, select them and then right click on them move cursor on "align" and select your choice or you can choose same size for all.
I don't know if you can change the default height of a text object. I've never tried this before but you might be able to use CSS to accomplish this.
I'm not exactly sure how you got into this situation - I've looked all over and can't find a way to modify the default height of a text object in the version you're using (and it is 0.16 inches for my install).
Assuming reinstalling is out of the question (this would be drastic but is probably your best bet), an alternative workaround may be to create an empty text object at the top of a report, manually set it to the correct height, then copy-pasting it anywhere you want a new one instead of using the insert menu.

Border in Detail band

I have a question about how border should display in detail band, and I would like to get some help.
Say, a column in detail band that might have LOTS data, by lots, I meant sometimes a single record might actually took 2~3 page to display.
Now customer ask that we should make report always display bottom line of the border as long as it meets end of page (even this record its not end yet)
What I tried:
Make a column footer with 1px height line.
Set "Floating column footer" to TRUE.
Result : It works great, but this line will make extra empty space at end of the table if there is a Summary band after the column footer. I think I am close, but I just can't get rid of the strange empty space
Make a Frame with border, set "Print when detail overflow" to TRUE then put everything in detail band into this frame.
Result : Not work as I expected :(
Since this report contains not just a table in detail band, and the height of the table are random. Tricks like a border in Background or Page Footer are not suitable here
What else can I do ?
There is a PrintWhenExpression trick that can help with the page footer:
How to hide Page X / Y when report is 1 page ? - JasperForge Forum
The trick is to put a flag in the Report Parameter Map, then use the flag to decide whether text (or fields, lines, etc.) should be printed.
To use a line in Page Footer there will always be some pages with extra line. In this case, the report is always starting from page 1, and the table in the report always end before printing the Summary band. That means, the line is no longer necessary as long as Summary band has been reached. Thus:
Add a line in Page Footer with PrintWhenExpression :
new Boolean(!(Boolean.TRUE).equals($P{REPORT_PARAMETERS_MAP}.get("stopFlag")))
Then make a dummy textField in Summary band with PrintWhenExpression like this :
$P{REPORT_PARAMETERS_MAP}.put("stopFlag",Boolean.TRUE)
This trick works, but might need some tweaking for different layouts.
The option given by Dave is right.
If you care about the space still being used, then set the band and textfield heights to zero.
In my case using Dave's option worked (and I needed no extra space to be used).
I put this as PrintWhenExpression in the fields I just wanted to show in the last page:
$P{REPORT_PARAMETERS_MAP}.get("lastPage")!=null
And this as PrintWhenExpression in a 0-height textfield in the 0-heigth summary band:
$P{REPORT_PARAMETERS_MAP}.put("lastPage",":)")
When it comes to page termination the options are limited. Its made even hard because if you have items that do not display when null it still assumes that space is used.
I would stick with messing around with the column footer or page footer as your best options.