English 中文(简体)
该表的负责人和机关在创建国防军时,没有在第2页上与国防军保持一致。
原标题:The table header and body is not aligning in the 2nd page while creating pdf with TCPDF

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>

2nd page of the table

问题回答

我也存在同样的问题,因此,在撰写“超文本”之前,我就设置了X级职位。

$pdf->SetX(6);
$pdf->writeHTML($tbl_string, true, false, true, false,  C );

我只是删除了SetaX,并把它固定下来。

$pdf->writeHTML($tbl_string, true, false, true, false,  C );




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签