Dynamic page height to show 10 records per page with StretchWithOverflow property set to true - jasper-reports

I have 10 records per page (9 columns) in jasper using page break property. I have set StretchWithOverflow property to true for my detail band. So, when there is more data, my table gets enlarge vertically.
My problem is, if the data is more, it is not showing 10 records per page because in jasper we give static height of the page.
If i set more height of the page, then in that case if data is less, there is lots of invalid space on the report. Please help if someone faced this issue.

Issue Resolved.
I used frame (from Pallete ctrl+shift+8) within detail band and put all my cell data into frame. So, when page height is more, the blank space display instead of my last row height go increases.
Now, my cell could not stretched due to extra height of the page.

Related

Vertically center report footer in remaining space on page

Is it possible to vertically center my report footer in the leftover space at the end of the page? The size of this leftover section depends on number of data rows.
There's no easy way to vertically center things in Crystal. Frustrating as it may be, there's no Vertical Alignment property on most things, and the Size/Position of things is static except when other objects push them around to make room for themselves.
However there is a ridiculously silly hack you can do to make this work.
Write a formula, let's call it SillySpaceFormula, that uses a loop to generate a certain number of return characters. Based on the number of records on this page, SillySpaceFormula will grow or shrink inversely. Set Silly's font size to be half the size of your details section. Then place this formula in a section above the orange-outlined box and set "Can Grow" to True.
If you do this just right, SillySpaceFormula will grow by one line when a record is removed and shrink by one line when a record is added. Because the formula field Can Grow, the orange box in your screenshots will be moved up and down automatically.

Hide Detail Band in jasper report

Data that we get from data source is not shown in detail band. But make some processing for each of records and processing result is shown in Group footer.
So I cannot remove detail band, as it is the only place for processing individual record. But I want to hide it, making invisible.
If I use printWhenExpression, it causes not only hiding the detail band but also no processing is done for records.
What I want is just hide(making invisible and do not make any blank) but processing is done for each iteration. If possible, may I know how to do it.
Remove all elements (static text, text field and so on) from detail band and set height = 0 px at detail band property
You can either set its height to 0 px in the properties section on the right side
OR
You can Right click > delete band. (The band can later be added back if needed).

Detail band resize dynamically vertically when textfield is NULL

I have a JasperReports report build with iReport. I have the normal Detail band but below i have a textField named observations there is sometimes the Observations textField is empty or NULL. I have put both inner components namely textfields, lines into frames something like.
I also set using Print When Expression the below frame the one who holds the Observations textField to appear only when there is data on it this is working very good but the space holds by the frame is still on the Detail and we are losing some space and it's kind annoyng to see this blank space.
Is it possible for the report to "delete" the idle space hold it by the hidden frame?
My report's design:
The generated result (PDF file):
I don't think it's possible to alter the height of a band depending on its content but you can actually have multiple detail bands. So add a new one, move your observation text field into it and set the print when expression of the second band.

iReport Designer - dynamic list and page number

I have put a list inside a rectangle with Relative to Tallest Object property which is inside a frame with Float property. All the components are inside the detail band. The size of the list component depends on the list which is sent from my Java application.
When I print a report with 100 objects inside a list, all records are not printed inside a rectangle. I don not know how I can fix it. Just the first page has a rectangle.
Also, I have a problem with page number. I put the page number variable at the bottom of the detail band with maximum height, but it is printed just on the first page. On other pages there is no any page number.
It would great if someone can help me.

How to fix the number of rows while designing pdf using iText in java

I am creating one pdf file showing a list of all employees and their salaries. At the end of the page it is showing the total of all salaries.
I am using a for loop to add multiple rows to table.
The problem is:
at the end the row, the total salary doesn't fit on the same page and it is shown on the next page.
So is there any way that I can calculate the height of the page and then fix the height of each cell? And then accordingly, limit the number of rows.
So that at the end of the page, I can show the total number of rows and further record from next page.
Calculate the height of the page: well... you decide on the size of the page when you create a Document object. You can choose any size you want.
Calculate the height of a PdfPTable: that's explained in chapter 4 of my book. When you create a PdfPTable, you add PdfPCell objects to an object that only exists in memory and that doesn't know anything about page size. By default, the width is expressed as a percentage of the available width of the page to which you'll add the PdfPTable. Only when you add the PdfPTable to a specific Document, the exact width and the height will be calculated (which is too late for you).
If you want to know the height in advance, you need to define an absolute width (not a percentage). Tables with the same content and a different width will have a different height. Defining an absolute width is done like this:
table.setTotalWidth(width);
table.setLockedWidth(true);
In this snippet (taken from the TableHeight example), width equals the width of the page minus the left and right margin. You're defining the width of the page and the margins upon creation of the Document object. By default, the page size is A4, so the default width is 595 user units and the default margins are 36 user units.
So, one way to solve your problem, would be to add rows in a loop and calculate the height of each row with the getRowHeight() method or the height of the complete table with the getTotalHeight() method (both methods will return 0 if you omit setting the total height). If you see there's not enough space to add the summary row, you can use the deleteLastRow() method to remove that last row and to create it anew in a new table on the next page.
That's one solution. Another solution could be to use table and cell events, but that's more difficult to explain.