3

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Nal
  • 121
  • 2
  • 15
  • If the tables are too large for one page, what else should happen than the creation of a new page? – Jens Dec 14 '14 at 11:35
  • Is it OK for you if the table is split into two parts? If so, why don't you change the "set split late" property to `false`? – Bruno Lowagie Dec 14 '14 at 14:04
  • @BrunoLowagie Yes that worked! Thanks. You can answer below and I'll accept answer. – Nal Dec 15 '14 at 07:33

1 Answers1

4

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • For some reason this only worked when I added it to every single table on my PDF, tried only adding to the one I needed and I was still getting a split. Hopefully this helps someone else, trial and error helped me get this to work. – Taylor Brown Mar 04 '19 at 18:16