插入带动态数据PHP页码的mpdf TOC

时间:2017-08-16 07:20:37

标签: php pdf mpdf tableofcontents

我正在使用mpdf从数据库中提取的数据创建PDF文件。 pdf中有三个部分,我需要在TOC中显示它们出现的页码。当数据太短时,它们也可以出现在单独的页面上或单个页面上。以下是我目前使用的代码:

    $mpdf = new \Mpdf\Mpdf();
    $mpdf->SetFont('avenirnext');
    $mpdf->SetTitle($title);
    $mpdf->SetAuthor('Blavatnik');
    $mpdf->WriteHTML($stylesheet, 1);
    $mpdf->WriteHTML($stylesheet2, 1);
    $mpdf->WriteHTML($stylesheet3, 1);
    $mpdf->setAutoTopMargin = 'stretch';
    $mpdf->SetHtmlHeader($header, 'OE');
    $mpdf->SetHTMLFooter($footer, 'OE');
    $mpdf->AddPage('', // L - landscape, P - portrait 
            '', '', '', '', 20, // margin_left
            20, // margin right
            5, // margin top
            25, // margin bottom
            10, // margin header
            10); // margin footer
    $mpdf->WriteHTML($html);
    $mpdf->Output($title . '.pdf', 'd');

我需要在首页上显示TOC,它还有一些设计,所以我认为必须通过html完成,如下例所示:

https://mpdf.github.io/what-else-can-i-do/table-of-contents.html

0 个答案:

没有答案