Yii2-kartik-v / mpdf-页眉仅在第一页

时间:2019-06-04 16:48:13

标签: yii2 mpdf kartik-v

我有一个模板,其中的页眉,内容和页脚以PDF呈现。 可能仅在第一页中显示标题吗?有可能吗?

$pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            //Name for the file
            'filename' => 'test.pdf',
            // A4 paper format
            'format' => Pdf::FORMAT_A4,
            // portrait orientation
            'orientation' => Pdf::ORIENT_LANDSCAPE,
            // stream to browser inline
            'destination' => Pdf::DEST_BROWSER,
            // your html content input
            'content' => $content,
            // format content from your own css file if needed or use the
            // enhanced bootstrap css built by Krajee for mPDF formatting
            'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
            // any css to be embedded if required
            'cssInline' => '.kv-heading-1{font-size:18px}; ',
            // set mPDF properties on the fly
            //'options' => ['title' => 'Krajee Report Title'],
            // call mPDF methods on the fly
            'methods' => [
                'SetHeader'=>$header,
                'SetFooter'=>$footer,
            ],
            'options' => [
                'setAutoTopMargin' => 'pad',
                'defaultfooterline' => false,
            ],
        ]);

1 个答案:

答案 0 :(得分:0)

如果像往常一样使用CSS设置页面样式,您可能会发现@page选择器很有用。应该是这样的:

@page {
   header: html_otherpages;
}

@page :first {
    header: html_firstpage;
}