iTextSharp table cell content only display complete content in second page directly due to long content - itext

I had search some relative question which had been asked, but seem not too much my condition.
My problem is simpler to this problem
Table in iTextSharp is not page breaking as desired?
The different between my problem and his is I need header in each extend page.
Currently I put a long table in one of cell, it make me has header in each page, but if the table to long, all table will shift to second page, and first page is empty.
I have tried table.KeepRowsTogether, but the 15 rows stay in second page and rest in third..

I determine what is the length of list. if number of items more than 15 then I separate list into 0 ~ 14 and 15th to the end, keep all content in the same table then there will having header in second page. Case close

Related

Table remove column header if no columns on page

I have a JasperReports's report with some data and a table. The problem is when the table splits on 2 pages sometimes on the first one is only the header of the table. I want it to split (can't use Prevent), but only if it is at least one line of detail (if not, all should move to the next page).
Bad Here:
Good Here:
On the first example (the bad one) first header should not be printed.
Ideas?
Put your table header into a group header, then follow the advice on the question:
In jasperreports how to force page break before a group title if there is no room for any subsequent rows

iTextSharp - finding end of page

Is there any way to find the current page is going to end in iTextSharp. For example,
say there are some 10 records which needs two pages to be written down at the end of the first page i wish to add '(contd on nex page'). IS there a way to do this. Will finding the end of page be an answer for this or is there a way to find the line number on which writing is done, so that i can make a calculation to decide whether to add a message of my choice and proceed to the next page.
any advise is much appreciated :)
Thanks a zillion
Usually, this is done by defining a footer for the table. When the table breaks automatically, iText will show that footer. Of course: you don't want this footer to show up on the last page (after the final row of the table). That's why there's also a method to skip the last row.
This example shows you how to create a table with headers and footers. This is the link to SkipLastFooter.
Note that saying that "finding the line number" would solve your problem is wrong for two reasons:
There is no such thing as a line number in a PDF file. You have a MediaBox and you draw content on the canvas defined by the MediaBox using coordinates.
There's a way to get the current Y-position on a page after adding an object to a document. You can get the Y-position before adding a table and after adding a table, but not while you're still creating the table.
An alternative solution to the one I suggested above, woult be to use table events.
If you really need to find the end of the page, and are not using a table with a footer row that will be printed at the end of each page, you can use the PdfWriter object as follows:
var remainingPageSpace = pdfWriter.GetVerticalPosition(false) - pdfDocument.BottomMargin;
This will give you the remaining space on the page, from which you can determine what you want to do next.
If you are using tabular data however, it is much preferred to use a PdfPTable and take advantage of the footer row feature.

Export PDF and supress page breaks

When I export my report to pdf, appear me weird page breaks.
If a lengthy report, that happens to me is that if a table does not fit in the remaining space of a page, it automatically passes me to the page below, thus creating blanks spaces.
Already have enabled the property Keep Together, interactive size to 0 and i unchecked keep together on one page if possible in tablix properties.
However I think the problem is not in the table, because before that, I have a textbox with a title, and is between the table and the textbox that makes page break.
I have already put the textbox and table inside a rectangle, but still have this problem.
Any suggestions?
Q: is the table / text box that responsible for the page break issue is inside a Subreport ?
If so, then this is your problem (unless you make a call that this table will always be short enough to stay in single page).
You have to understand: the subreport is the cause for the breaking, the table will not split because it is presented by the sub-report that has to stay in one piece.
The options are:
Stay with the subreport - but make sure that the table Maximum length will still fit the Page that the sub-report is lay in it.
take out the table from the subreport and place it directly in the main report - that way when the table too long to stay in single page, it will split into two pages.

SSRS unusual Pagebreak in a long text

i am creating a report for SQL Server 2008.
i have a table with some rows. One of the row has a long text which will be displayed. If the text has a certain length, the whole row will be displayed on the second page and the half of the first page is empty.
If the text is a bit shorter, the text will be displayed correctly on the first page.
If the text is a bit longer, the text will also be displayed correctly (the first part of the text on the first page, the second part on the second page).
I cant find any settings for this problem.
Does anyone have a solution?
Thanks
Alex
You could look at the Keep together on one page if possible setting at the Tablix level.
You can also look at the KeepTogether property at the row level and at other levels, e.g. Group.
Another option is to insert any objects to be kept together in a parent Rectangle object; this will always keep items together where possible.

iTextSharp and moving some data to next page

I am creating an invoice using the iTextSharp. That displays nicely but sometime, when invoice items are larger in qty, the summary portion (which displays subtotal, tax, discounts, grand total etc) is splitted. Some displayes in current page and some moves to next page. I was thinking to move entire summary portion into next page, if current height left is not enough for that.
However, to do that, I need to know that how much page height is left (after my current page content rendering). I wonder if someone know how to calculate current left height of the page? OR if there is a property in the pdfPTable which may force the table to print itself as a whole and dont let it split across multiple pages! I guess if second option is available, it will be easy.
In summary, I need to know if it is possible to calculate remaining page height, and also if that is possible to force a table to NOT split across multiple pages.
thank you.
Sameers
You can set SplitLate to false to avoid auto page break in a cell data exceeds limit.
......
table.addCell(cellData);
table.SplitLate = false;
......
I suggest you use a nested table for your summary section. I don't believe iText will split a given cell on a page boundary, so everything in that cell (even if its a nested table with cells of its own) will stay on the same page.
Use the table's cell's row span so it takes up an entire row on its own.
I'm not certain, but I'd wager a beer on it.
What object are you using to add your data to the PDF? MultiColumnText, Paragraph, Phrase?
You should be able to use Document.PageSize.Height property to return the height of the Page.
Then use PDFPTable.Height to return the height of your table.
So just use the logic Document.PageSize.Height - table.Height, and you'll have the remaining y-axis space available.
The PDFPTable object has properties named SplitLate and SplitRows. I believe you can use these properties to try and keep the table on one page.