How to make a table not break with iTextSharp

I have a table

PdfPTable tblSummary = new PdfPTable(1); 

And he has two tables nested in it. How can I make tblSummary displayed as a whole (rows should not be split on another page), or the whole table will be moved to another page if it does not fit on the current page.

I 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 am adding another table to tblSummary, while the resulting table height is always less than the page size, so there is confidence that the contents of the table will not be greater than the page height.

Any suggestions really help.

+6
source share
2 answers

Have you tried this:

 tblSummary.KeepTogether = true; 
+24
source
 PdfPTable tabla = new PdfPTable(2); float[] anchosTablaTituloDescripcion = new float[] { 4f, 4f }; tabla.SetWidths(anchosTablaTituloDescripcion); tabla.WidthPercentage = 100; tabla.KeepTogether = true; 
+1
source

Source: https://habr.com/ru/post/901689/


All Articles