Forum


Replies: 0   Views: 2353
Workaround to prevent page break inside whole table.
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 bdm  · 01-08-2018 - 01:43

I was looking for solution how to prevent my whole SMALL  table from breaking in one page for daysssss. 

page-break-inside:avoid; works only in specific table row (tr) or in paragraph but not in table.

You can try to place your table inside another table. 

<table>
  <tr style="page-break-inside:avoid;">
     <td>
         <table>
            <tr><td></td></tr>
            <tr><td></td></tr>
            <tr><td></td></tr>
            <tr><td></td></tr>
         </table>
     </td>
  </tr>
</table>

and VOILA!!! 

Your table won't break inside one page. 

NOTE: this workaround is not advisable to use in long table cause rows could go endless. Use only in small table or when you think table would fit in one page.

Enjoy.

P.S.... I know too many tables inside your code looks ugly...but it serves my purpose.