Replies: 8   Views: 3948
Embed html and page-break-inside property
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 11-09-2017 - 08:34


We have checked it and it's working fine after applying the previous lines to But due to how MS Word works, you need to add the page-break-after style to accomplish what you need.

This is a simple sample that illustrates how to do it (you can use inline styles or a external CSS):

$html = '
<p style="page-break-inside: avoid;">
   <p style="page-break-inside: avoid; page-break-after: avoid;">Some text</p>
       <li style="page-break-inside: avoid; page-break-after: avoid;">Item 1</li>
       <li style="page-break-inside: avoid; page-break-after: avoid;">Item 2</li>

If you open the DOCX with MS Word, you can see that the paragraph and lists have the keep with next option enabled and act as a 'block' for the content page.

On the snippets section ( you can find some samples about this same question.