Keep table on same page

To prevent or avoid a Table element from being split across pages, we need to format Paragraph elements inside that Table element so that their KeepLinesTogether and KeepWithNext properties are set to True.

For the demonstration, we will create a new document with a Table element that will not fit on a single page:

Now, to keep the whole Table element on the same page, before saving the DocumentModel we'll iterate through the Table element's child Paragraph elements and set their ParagraphFormat.KeepLinesTogether and ParagraphFormat.KeepWithNext properties to True: