Keeping a block together

I’d like to add a section to my document that continues where the previous section ended (section.PageSetup.SectionStart = SectionStart.Continuous;) but keep the first block together. If the whole block doesn’t fit on the remaining page space, put it on the next page.
Is this possible?

Hi,

Without investigating your document I cannot say for sure, but I believe you want something like this:

var paragraph = section.Blocks.OfType<Paragraph>().First();
paragraph.ParagraphFormat.KeepLinesTogether = true;

Does this solve your issue?

Regards,
Mario

Hi Mario,
I would like the Section 2 heading to always stick with the table below it, so if table 2 does not fit on the page due to the size of table 1 it should move to the following page along with the Section 2 heading.

From Microsoft Word, select the “Section 2” paragraph and the whole Table element below it.

Then check these two paragraph options on them:

The paragraphs are behaving as expected in the word document however when converted to PDF the heading does not keep with the table below

Please send us your Word file so that we can reproduce the issue and investigate it.