Nal Nal - 1 year ago 80 Question

iTextSharp table pushing another table to a new page

I have two tables on my PDF. The first one sometimes spans more than half the page, which forces the second to jump to a new page.

Here are my definitions:

'Table Declaration
Dim sglTblHdWidths(2) As Single
sglTblHdWidths(0) = 200
sglTblHdWidths(1) = 200
sglTblHdWidths(2) = 102
'Table ONE:
Dim ToCCSub As New PdfPTable(sglTblHdWidths)
ToCCSub.TotalWidth = 502.0F
ToCCSub.LockedWidth = True
'Table TWO:
Dim tab As New PdfPTable(1)
tab.TotalWidth = 502.0F
tab.LockedWidth = True

And they're both added to the document afterward. How can prevent this from happening?

Answer Source

By default, iText won't split a row, but instead forward it to the next page. You can change this default by changing the value of the SplitLate property:

tab.SplitLate = false;

Now the row in the table tab that was shown on the next page, will be split into two parts, so that the content is distributed over the current page and the next page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download