【问题标题】:Table heading on every page using MPDF使用 MPDF 在每一页上的表格标题
【发布时间】:2021-01-13 05:03:08
【问题描述】:

我希望在使用 MPDF 库生成 pdf 时在每一页上显示表格标题。

$mpdf = new \Mpdf\Mpdf([
'mode'=>'utf-8',
'format' => 'A4-L'
]);

$mpdf->SetHTMLHeader("<table>
                    <tr>
                          <th>Sl No.</th>
                          <th>Name</th> 
                    </tr>
");

for($i=0; $i<500;$i++){
      $mpdf->WriteHTML("<tr>");
      $mpdf->WriteHTML("<td>".$res[$i]["slno"]."</td>");
      $mpdf->WriteHTML("<td>".$res[$i]["name"]."</td>");
      $mpdf->WriteHTML("</tr>");                       
                       
                   
}
      $mpdf->WriteHTML("</table>");

【问题讨论】:

    标签: php mpdf


    【解决方案1】:

    只需使用&lt;thead&gt; 标签。在页眉之外。

    $mpdf->WriteHTML('
    
    <table>
    <thead>
        <tr>
            <th>Sl No.</th>
            <th>Name</th> 
        </tr>
    <thead>
    
    ...');
    

    https://mpdf.github.io/tables/tables.html#repeating-table-header-row-on-new-page

    【讨论】:

    • 将答案标记为已接受并考虑投票。
    猜你喜欢
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    相关资源
    最近更新 更多