From aspx page, I dynamically add paragraphs to a word document using OpenXml SDK. In this case, a page break within a paragraph is not allowed. So in case a paragraph starts in middle of page 1 and extends to page2 then it should actually start in Page2. However, if it ends in the same page it is okay.
How to achieve this? Is there a way to set in th document that page break is not allowed within a paragraph? Any input is highly appreciated.
In general you can not use the open xml sdk to determine where in a page an element will be displayed, since open xml has no concepts of pages.
Pages are determined by the client application consuming the open xml document. You can however specify that a paragraph’s lines are kept together.
w:keepLines in the above examples paragraph properties is the key to making sure a paragraph is not split up between pages, below is the open xml required to generate the above paragrpah: