Forum


Replies: 8   Views: 4143
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

Hello,

We have checked it and it's working fine after applying the previous lines to HTML2WordML.inc. 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>
   <ol>
       <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>
   </ol>
</p>
';
$docx->embedHTML($html);

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 (https://www.phpdocx.com/documentation/snippets/) you can find some samples about this same question.

Regards.