0

I'm generating reports from a .docx document using HtmlToOpenXml.

I need to ensure that a particular html block will be displayed on the same page, for example:

<p>Video provides a powerful way to help [...]</p>
<br />
<br />
<p>To make your document look professionally [...]</p>

I took a look around the web:

<w:pPr><w:keepNext/></w:pPr> had my attention but I'm not sure that I can put two paragraphs inside a larger one.

I'm aware that it will depend of the font, size and so on but it will not change.

Community
  • 1
  • 1
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142

1 Answers1

1

Use "page-break-inside" style in your first block surrounding content to move it to new page. Then try to keep other blocks small enough to fit page (no matter how hard you will try, if the content is too big, it won't fit on one page). Like in example:

<div style="page-break-inside: avoid">
    <p>Video provides a powerful way to help [...]</p>
    <br />
    <br />
    <p>To make your document look professionally [...]</p>
</div>

Take a look at documentation here: CSS page-break-before Property

Misiakw
  • 902
  • 8
  • 28