DOMPDF(0.8.3):跳过具有标题的第一页 [英] DOMPDF(0.8.3): Skip the 1st page having header

查看:88
本文介绍了DOMPDF(0.8.3):跳过具有标题的第一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用dompdf版本0.8.3.我们在每个页面中都添加了一些标题,但我们希望标题仅出现在第二页以后.

I am using dompdf version 0.8.3. We added some header in each page but we want the header will only appear on the 2nd page onwards.

我们现在所拥有的是每页上都有页眉和页脚,但是当页面从第二页开始时,我们想显示'P O#:number?> .

What we have right now is we have header and footer on each page but we want to display the 'P O #: number ?> when the page is 2nd page onwards.

控制器

<!-- My other function/data -->
$pdf = PDF::loadView('purchase-order.export.export-pdf', $data)->setPaper('a4');
$pdf->getDomPDF()->set_option("enable_php", true);
return $pdf->stream('purchase-order-'.$purchase_order->number.'.pdf');

PDF

<style type="text/css">
    @page {
            margin-top: 40px !important;
            margin-bottom: 50px !important;
        }
</style>
<div class="page-break">
    <div id="page-wrap">
        <script type="text/php">
            if (isset($pdf)) {
                $x = 25;
                $y = 800;
                $text = "page {PAGE_NUM} of {PAGE_COUNT}";
                $page_num = "{PAGE_NUM}";
                $text2 = "This is a system generated document";
                $font = 'Arial';
                $size = 11;
                $color = array(0.333,0.333,0.333);
                $word_space = 0.0;  //  default
                $char_space = 0.0;  //  default
                $angle = 0.0;   //  default
                // header
                $pdf->page_text(500,10,'P O #: <?= $purchase_order->number ?>',$font,$size,$color,$word_space,$char_space,$angle);
                // footer
                $pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
                // generated
                $pdf->page_text(410, $y, $text2, $font, $size, $color, $word_space, $char_space, $angle);
            }
        </script>
    </div>
</div>

问题:是否可以跳过第一页以获得标题?

Question: Is it possible to skip the 1st page to have the header?

推荐答案

如果我的问题正确,我相信您想跳过第一页,在第二页上显示页眉,页脚和生成的文本,依此类推.您可以添加条件以检查当前页面是什么,然后仅在该页面大于1时显示页眉分页:

If I got your question right, I believe you want to skip first page and display your header, footer and generated text on second page, and so on. You can add condition to check what's the current page and then display header pagination only if that page is greater than 1:

if ($page_num > 1) {
  // header
  $pdf->page_text(500,10,'P O #: <?= $purchase_order->number ?>',$font,$size,$color,$word_space,$char_space,$angle);
  // footer
  $pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
  // generated
  $pdf->page_text(410, $y, $text2, $font, $size, $color, $word_space, $char_space, $angle);
}

这篇关于DOMPDF(0.8.3):跳过具有标题的第一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆