首页 文章

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

提问于
浏览
1

我正在使用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();
}

View

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/> 似乎没有呈现第二页?

1 回答

  • 6

    尝试简单地创建包含页面和添加的视图

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

    更简单的方面是管理两个页面..

    这是来自http://mpdf1.com/manual/index.php?tid=108

    您可以使用HTML代码或PHP强制在文档中的任何位置分页:

    $mpdf->AddPage();
    
    <pagebreak />
    

相关问题