Hi,
We try to prevent a page break inside a table/paragraph. Unfortunately nothing seems to work. (see shortened code below).
Using addTable isn't an option, we want to allow users to insert tables, images etc. Currently we only have libreoffice, editting table styles is not yet supported.
protected function generateTable(array $tableData) {
$html = '<style>
p {page-break-inside:avoid;}
table{ width: 100%; padding:0px;margin:0px;text-align:left;page-break-inside:avoid;font-size:8pt;}
tbody {page-break-inside:avoid;}
tr{ page-break-inside:avoid; }
td{border: 1px solid #222;page-break-inside:avoid;}
th{border: 1px solid #222; text-align:left;page-break-inside:avoid; font-weight:normal;}
</style><p><table><caption>test caption</caption>';
foreach($tableData as $name => $value) {
$html.= '<tr>';
$html.= '<td style="width:40px;">'.trim($name).'</td>';
$html.= '<td style="width:80px;">'.trim(nl2br($value)).'</td>';
$html.= '</tr>';
}
$html.= '</table></p><br />';
return $html;
}
$createDocx = new CreateDocx();
$createDocx->embedHTML($this->generateKeyValueTable($tableData, array('strictWordStyles' => false)));
Kind Regards,
Aristoteles