Forum


Replies: 2   Views: 861
Group items to prevent page breaks inside the group
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  · 18-09-2021 - 08:21

Hello,

You need to enable keepLines and keepNext options:

$docx->addText('Text content', array('keepLines' => true, 'keepNext' => true));

Please note that these options move the content to the same page of the next content, so this text will be moved if the whole table is in the next page. You can also use the addHeading method that applies those styles automatically.

If you want to keep a content and a whole table in the same page even if only some rows are not in the same page, please check the documentation available on https://www.phpdocx.com/documentation/snippets/prevent-page-break-table-add-table (you need to apply keepNext and keepLines in all paragraphs of the table).

Regards.