我正在使用codeigniter而且我有一个很长的观点,我需要一个分页,但它没有正常工作。我试图应用这个例子:https://mpdf.github.io/paging/page-numbering.html但最终得到一个空白页面作为第1页?
$pdfdata = $this->load->view('pdf/pdffile', $data, true);
$pdf2 = $this->m_pdf->load();
$pdfFilePath2 = uniqid(rand(), true);
$pdfFilePath_2 = "pdffile-".date('Ymdhis')."-".$pdfFilePath2.".pdf";
$pdf2->setHeader('{PAGENO}');
$mpdf->WriteHTML('<pagebreak resetpagenum="1" pagenumstyle="1" suppress="off" />');
$pdf2->WriteHTML($pdfdata);
$pdf2->Output("./uploads/".$pdfFilePath_2, "F");
我希望标题有像“N页的第1页”一样的分页,但我没有得到示例,总是给我一个木板页面作为第1页。任何想法?
您将获得一个空的第一页,因为您写入mPDF的第一件事是分页符。
在pagebreak
元素之前写一些内容以在第一页上包含内容。如果你真的不需要,请省略pagebreak
元素。
要显示所需的分页,请使用
$pdf2->setHeader('{PAGENO} of {nbpg}');