使用 mpdf 将内容添加到第二页

Add content to second page with mpdf

我正在使用 https://github.com/kartik-v/yii2-mpdf 在 Yii2 中创建 PDF。我有第一页,但我需要添加一个分页符并确保我在新页面上开始第二条信息。我不确定该怎么做。我试过:

    public function actionReports()
{
  $data = date('d F Y',time());
  $content = $this->renderPartial('_billing', [
    'model' => $data,
  ]);

  $doc = new Pdf([
    // set to use core fonts only
    'mode' => Pdf::MODE_UTF8,
    // A4 paper format
    'format' => Pdf::FORMAT_A4,
    // portrait orientation
    'orientation' => Pdf::ORIENT_PORTRAIT,
    // stream to browser inline
    'destination' => Pdf::DEST_BROWSER,
    // your html content input
    'content' => $content,
  ]);

  return $doc->render();
}

查看

use yii\helpers\Html;

?>
<div class="container">
<div class="row">
<div class="col-lg-6 col-lg-offset-3 text-center">
  <?= Html::img(\Yii::getAlias('@web') .  '/images/c.png'); ?>
  <?= Html::img(\Yii::getAlias('@web') .  '/images/s.png', ['width' => 150, 'height' => 55]); ?>
</div>

<div class="col-lg-12  margin-add">
<h4 class="text-center text-gray">Quarterly Billing Summary</h4>

<p><?= $model; ?></p>
....
rest of text
....
<pagebreak/>
...
Tabulated report of billing
...

<pagebreak/> 似乎没有呈现第二页?

尝试简单地创建一个包含两个页面的视图并添加

"<pagebreak/>" in view where you need this will create page break

管理两个页面更简单..

本文来自http://mpdf1.com/manual/index.php?tid=108

您可以使用 HTML 代码或 PHP:

在文档中的任何位置强制分页
$mpdf->AddPage();

<pagebreak />
$invoice_nos = ['0' => $html, '1' => $html, '2' => $html];

$this->mpdf= new mPDF('TH','A4');
$this->mpdf->defaultheaderfontsize=12;
$this->mpdf->defaultheaderfontstyle='B';
$this->mpdf->defaultheaderline=0;
$this->mpdf->setFooter($footer);
$this->mpdf->SetHeader('Bill | | <strong>Pages {PAGENO} of {nb}</strong>');

foreach ($invoice_nos as $key => $invoice_no) {

 $this->mpdf->AddPage();
 $this->mpdf->WriteHTML($html);
}

$this->mpdf->defaultfooterline=0;
$this->mpdf->Output();
$this->mpdf->Output('.date('Y-m-d').'.pdf','F');