Free Support Forum -

AllowBreakAcrossPages does not PDF properly with nested tables

We have a set of simple nested tables. Internally there are a set of tables with 10 rows and each of these tables need to be kept together. We have tried nesting each of these 10 tables in a single cell table with the AllowBreakAcrossPages set to false.If I save the document in Word and open the .docx file it looks perfect.If I save as PDF, the tables break across pages.

Sample code is attached.

Can this be fixed?


Hi Todd,

Thanks for your inquiry. Actually, to achieve what you need it is not necessary to use nested tables. It would be enough to use KeepWithNext option as shown in the code below:

Dim doc As New Document()

Dim wrdDoc As New DocumentBuilder(doc)

Dim HeaderRow As Aspose.Words.Tables.Row

Dim BodyRow As Aspose.Words.Tables.Row

Dim SingleRowTableRow As Aspose.Words.Tables.Row


wrdDoc.InsertCell() ' title cell

wrdDoc.Write("Header Row")

HeaderRow = wrdDoc.CurrentParagraph.GetAncestor(GetType(Aspose.Words.Tables.Row))

wrdDoc.EndRow() ' title cell

For i As Integer = 1 To 10

wrdDoc.RowFormat.AllowBreakAcrossPages = False

' 10 row in table are keep togather

For j As Integer = 1 To 10

wrdDoc.Font.Size = 10


' enable keep with nex option for each paragraph except the last one in the sequence.

wrdDoc.ParagraphFormat.KeepWithNext = (j <> 10)





' set the header row to repeat

HeaderRow.RowFormat.HeadingFormat = True




Hope this helps.

Best regards,