I want to generate an invoice with TCPDF which contained a dynamic table depends on the size of the items. It works fine until the table size does not cross the first page. From the second page the table header shifts to the left which breaks the alignment between the table-header and the table-body. I don t know how to fix this! N.B: I do not have multiple table. It is a single table invoice.
<table style="font-family:Arial, Helvetica, sans-serif;border: 1px solid #ddd;padding: 3px">
<thead>
<tr style="line-height:20px;background-color:#F7F7F7">
<th style="width: 40px; text-align: center;">#</th>
<th style="width: 190px;">Product</th>
<th style="width: 80px; text-align: center;">Quantity</th>
<th style="width: 50px; text-align: center;">Unit</th>
<th style="width: 80px; text-align: right;">Price (BDT)</th>
<th style="width: 92px; text-align: right;">Amount (BDT)</th>
</tr>
</thead>
<tbody>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">01</td>
<td style="width: 190px;"><b>Mouse</b><br><span style="font-size:10px">LOGITECH B175 WIRELESS MOUSE</span>
</td>
<td style="width: 80px; text-align: center;">5</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">500</td>
<td style="width: 92px; text-align: right;">2500</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">02</td>
<td style="width: 190px;"><b>Keyboard</b><br><span style="font-size:10px">Logitech G512 Lightsync RGB Mechanical USB Gaming Keyboard Black</span>
</td>
<td style="width: 80px; text-align: center;">13</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">3200</td>
<td style="width: 92px; text-align: right;">3966</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">03</td>
<td style="width: 190px;"><b>Pendrive</b><br><span style="font-size:10px">Adata 32GB USB 3.0</span>
</td>
<td style="width: 80px; text-align: center;">21</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">2750</td>
<td style="width: 92px; text-align: right;">37750</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">04</td>
<td style="width: 190px;"><b>Monitor</b><br><span style="font-size:10px">MSI G2412 23.8" 170Hz FHD IPS 1ms FreeSync Premium Gaming Monitor</span>
</td>
<td style="width: 80px; text-align: center;">6</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">24735</td>
<td style="width: 92px; text-align: right;">148410</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">05</td>
<td style="width: 190px;"><b>Headphone</b><br><span style="font-size:10px">Havit H2010d-Pro RGB Gaming Headphone</span>
</td>
<td style="width: 80px; text-align: center;">14</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">1150</td>
<td style="width: 92px; text-align: right;">16100</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">06</td>
<td style="width: 190px;"><b>Mouse</b><br><span style="font-size:10px">LOGITECH B175 WIRELESS MOUSE</span>
</td>
<td style="width: 80px; text-align: center;">5</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">500</td>
<td style="width: 92px; text-align: right;">2500</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">07</td>
<td style="width: 190px;"><b>Keyboard</b><br><span style="font-size:10px">Logitech G512 Lightsync RGB Mechanical USB Gaming Keyboard Black</span>
</td>
<td style="width: 80px; text-align: center;">13</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">3200</td>
<td style="width: 92px; text-align: right;">3966</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">08</td>
<td style="width: 190px;"><b>Pendrive</b><br><span style="font-size:10px">Adata 32GB USB 3.0</span>
</td>
<td style="width: 80px; text-align: center;">21</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">2750</td>
<td style="width: 92px; text-align: right;">37750</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">09</td>
<td style="width: 190px;"><b>Monitor</b><br><span style="font-size:10px">MSI G2412 23.8" 170Hz FHD IPS 1ms FreeSync Premium Gaming Monitor</span>
</td>
<td style="width: 80px; text-align: center;">6</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">24735</td>
<td style="width: 92px; text-align: right;">148410</td>
</tr>
<tr style="border: 1px solid black!important;line-height: 2;">
<td style="width: 40px; text-align: center; margin-top: 200px;">10</td>
<td style="width: 190px;"><b>Headphone</b><br><span style="font-size:10px">Havit H2010d-Pro RGB Gaming Headphone</span>
</td>
<td style="width: 80px; text-align: center;">14</td>
<td style="width: 50px; text-align: center;">Pcs</td>
<td style="width: 80px; text-align: right;">1150</td>
<td style="width: 92px; text-align: right;">16100</td>
</tr>
</tbody>
</table>
<style>
th, td {
border-bottom: 1px solid #e3e3e3;
border-top: 1px solid #e3e3e3;
}
table tr th {
color:black;
font-weight:bold;
}
</style>