php - In TCPDF how to tell if my table will be bigger than the page becouse in this case I would have to add a custom header for it -
in tcpdf how tell if table bigger page because in case have add custom header it. if use: $pdf->getaliasnumpage() compare before start table , @ beginning of each row don't seem work. $pdf->getaliasnumpage() if used second time return like: {:pnp:} hope can me this. code looks this:
<? $table=""; $islasttable = 0; ($i = 0; $i<sizeof($ar); $i++) { ($j = 0; $j<3; $j++) { if (isset ($ar[$i][$j])) { if($j==0) { if ($islasttable == 1) { $table .= '</table><table border="1" style="text-align:center; vertical-align:middle; padding:5;border-bottopm:1px solid black;">'; $islasttable = 0; } else { $table .= '<table border="1" style="text-align:center; vertical-align:middle; padding:5;">'; } $table .= '<tr > <td colspan="3">gefehrdungsfaktor</td> <td colspan="8">'.$ar[$i][$j].'</td> </tr>'; } if($j==1) { $table.=' <tr > <td colspan="3">gefahrebquelle</td> <td colspan="8">'.$ar[$i][$j].'</td> </tr>'; $flag = 1; } if($j==2) { if($flag == 1) { $level = " top level2 with: ".$arraytogeneratetable[$i].' childs'; $table.='<tr > <td colspan="11">risiko</td> </tr>'; $table.='<tr > <td colspan="1" style="font-size: xx-small; background-color:#f3a505">gk </td> <td colspan="5" style="background-color:#f3a505">(n)</td> <td colspan="2" style="background-color:#f3a505"> ?</td> <td colspan="2" style="background-color:#f3a505"></td> <td colspan="1" style="font-size: xx-small; background-color:#f3a505">gk </td> </tr>'; $table.='<tr > <td colspan="1" rowspan="'.(($arraytogeneratetable[$i])*2).'" style="background-color:grey">0</td> <td colspan="5" rowspan="2">'.$ar[$i][$j].'</td> <td colspan="1" rowspan="1">ja</td> <td colspan="1" rowspan="1">x</td> <td colspan="2" rowspan="2"> </td> <td colspan="1" rowspan="'.(($arraytogeneratetable[$i])*2).'" style="background-color:grey;">0</td> </tr> <tr > <td colspan="1">nein'.'</td> <td colspan="1">x</td> </tr>'; } else{ $table.='<tr > <td colspan="5" rowspan="2">'.$ar[$i][$j].'</td> <td colspan="1">ja</td> <td colspan="1">x</td> <td colspan="2" rowspan="2"> </td> </tr> <tr > <td>nein</td> <td>x'.'</td> </tr>'; } $level = ''; $flag=0; $islasttable = 1; } } } } $table.='</table>'; $pdf->addpage(); $pdf->writehtml($table, true, false, true, false, ''); ?>
one solution have:
<style> table{ table-layout: fixed; } td{ max-height:20px; } </style>
and can calculate number of lines.
Comments
Post a Comment