Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the table non breaking using iTextSharp

I am having a table

  PdfPTable tblSummary = new PdfPTable(1);  

And it does have 2 tables nested within it. How can I make the tblSummary to appear as a whole (the rows must not break to another page) or entire table be shifted to another page if it doesn't fits in the current page.

I have tried SplitLate and SplitRows

And my code is like this

PdfPTable tblSummary = new PdfPTable(1);
PdfPCell csummarycell = new PdfPCell();  
PdfPTable tblSummaryFirst = new PdfPTable(3);
.
.
csummarycell.AddElement(tblSummaryFirst);
.
.
tblSummary.AddCell(csummarycell);
tblSummary.SplitLate = true;
tblSummary.SplitRows = false;

like this I add up one more table(s) to the tblSummary while the resulting table height is always less than that of pagesize so there is certainty that the table's content won't be more than the page height.

Any suggestions would be really helping.

like image 368
Vinay Avatar asked Nov 17 '11 06:11

Vinay


2 Answers

Have you tried this:

tblSummary.KeepTogether = true;
like image 167
Rios Avatar answered Oct 06 '22 11:10

Rios


PdfPTable tabla = new PdfPTable(2);
float[] anchosTablaTituloDescripcion = new float[] { 4f, 4f };
tabla.SetWidths(anchosTablaTituloDescripcion);
tabla.WidthPercentage = 100;
tabla.KeepTogether = true;
like image 28
CARLOS HERNANDEZ Avatar answered Oct 06 '22 10:10

CARLOS HERNANDEZ