【问题标题】:Yii2 - kartik-v/mpdf - Header only in first pageYii2 - kartik-v/mpdf - 标题仅在第一页
【发布时间】:2019-06-04 16:48:13
【问题描述】:

我有一个带有 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,
            ],
        ]);

【问题讨论】:

    标签: yii2 mpdf kartik-v


    【解决方案1】:

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

    @page {
       header: html_otherpages;
    }
    
    @page :first {
        header: html_firstpage;
    }
    

    【讨论】:

    • 你应该是正确的,但我决定不这样做,我将$header的内容添加到$content变量中,所以没关系。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多