Php 如何在Dompdf laravel 5.5中使用分页符?

Php 如何在Dompdf laravel 5.5中使用分页符?,php,css,laravel,laravel-5.5,dompdf,Php,Css,Laravel,Laravel 5.5,Dompdf,我在设计系统的pdf时遇到问题。以下是我的pdf照片: 我想做的是将表中的项目数限制为10个项目,然后剩余的项目进入下一页,页眉和页脚相同,这已经是固定的。就这样, 这是我的密码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>PDF</title

我在设计系统的pdf时遇到问题。以下是我的pdf照片:

我想做的是将表中的项目数限制为10个项目,然后剩余的项目进入下一页,页眉和页脚相同,这已经是固定的。就这样,

这是我的密码:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>PDF</title>

    <link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
    <style>
        #items tr{border:1px solid #000000;}
        #items tbody tr td{border:1px solid #000000;}
        #items thead td{background-color:#231F20;color:#FFFFFF;}

        .header { position: fixed; left: 0px; top: -40px; right: 0px;}
        .footer { position: fixed; left: 0px; bottom: 200px; right: 0px;}
    </style>
    <link rel="stylesheet" href="{{ asset('css/lato.css') }}">
    <link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128" rel="stylesheet">



</head>
<body>
<div class="container-fluid">

<div class="header">
    <div class="row">

        <div class="col-xs-3" style="font-family: 'Libre Barcode 128', cursive; font-size: 35px;padding: 10px 0px 0px 0px;">{{$pr->pr_form_no}}</div>
        <div class="col-xs-9">
        <table cellspacing='0' cellpadding='5' style="border-width: 0 !important;padding:0px 0px 0px 60px;">
            <tr>
                <td style="padding: 10px;"><img src="{{asset('images/sfclogo.png')}}" width="50px" height="50px"></td>
                <td>
                    <table style="text-align: center;style='width:45%'">
                        <tr><td>REPUBLIC OF THE PHILIPPINES</td></tr>
                        <tr><td>PROVINCE OF LA UNION</td></tr>
                        <tr><td>CITY OF SAN FERNANDO</td></tr>
                    </table>
                </td>
                <th style="padding-top: 10px;padding-left: 10px"><p style="background-color: #000;color: #FFF; text-align: center;padding: 10px;">PR</p></th>
            </tr>
        </table>
        </div>
    </div>

      <div class="row">
        <div class="col-md-12" style="text-align: center;color: white;background-color: black; font-size: 18px">
            PURCHASE REQUEST
        </div><br>
      </div>

      <div class="row">
                <table style='width:100%;border:1px solid #000000;font-size:11pt;' cellspacing='0' cellpadding='5' class='font1'>
                <tr>
                    <td style='width:40%'>
                        <table style='width:90%;padding-right: 0px;' cellpadding='0' cellspacing='0'>
                            <tr>
                                <td style='width:100%;padding:1px;padding-left:10px;' colspan='2'>DEPARTMENT:</td>
                            </tr>
                            <tr>
                                <td style='width:100%;padding:0px;padding-left:10px;' colspan='2'>{{$dept->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;padding-left:10px;' /></td>
                            </tr>
                            <tr>
                                <td style='width:15%;padding:1px;padding-left:10px;'>SECTION:</td>
                                <td style='width:75%;padding:0px;padding-left:0px;'>{{$section->office_name}}<hr style='color:#000000;height:1px;margin-bottom:3px;margin-top:0px;' /></td>
                            </tr>
                        </table>
                    </td>
                    <td style='width:30%;'>
                        <table style='width:90%;' cellpadding='0' cellspacing='0'>
                            <tr>
                                <td style='width:20%;padding:1px;'>PR No.</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000000;'>{{$pr->pr_form_no}}</td>
                            </tr>
                            <tr>
                                <td style='width:20%;padding:1px;'>SAI No.</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
                            </tr>
                            <tr>
                                <td style='width:20%;padding:1px;'>ObR No.</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000000;'></td>
                            </tr>
                        </table>
                    </td>
                    <td style='width:30%'>
                        <table style='width:95%;' cellpadding='0' cellspacing='0'>
                            <tr>
                                <td style='width:15%;padding:1px;'>Date</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000000;'>&nbsp;{{$dt->toFormattedDateString()}}</td>
                            </tr>
                            <tr>
                                <td style='width:15%;padding:1px;'>Budget</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000000;'><strong>&nbsp;PHP {{number_format($pr->budget_alloc,2)}}</strong></td>
                            </tr>
                            <tr>
                                <td style='width:15%;padding:1px;'>Supplier</td>
                                <td style='width:70%;padding:0px;border-bottom:1px solid #000;'>&nbsp;{{$pr->supplier_type}}</td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
      </div>
  </div>

 <div class="footer">
    <div class="row">
        <table style='width:100%;border:1px solid #000000;font-size:12px;margin-left:auto;margin-right:auto;margin-top:40px;' cellspacing='0' cellpadding='3' class='font1'>
            <tr>
                <td style='width:39%; font-weight:bold;text-align:left;border:1px solid #000000;'>
                REQUESTING OFFICE<br/><br/><br/><br/>
                </td>
                <td style='width:60%;border:1px solid #000000;vertical-align:top;font-weight:bold;' colspan='2' rowspan='3'>
                PURPOSE<br/>
                <div style='width:100%;text-align:center;font-weight:normal;font-size:11pt;' class='font1'>
                    {{$pr->purpose}}
                </div>
                </td>
            </tr>
            <tr>
                <td style='border:1px solid #000000;height:19px;text-align:center;text-transform:uppercase;font-weight:bold;'>
                {{$pr->requestor_name}}
                </td>
            </tr>
            <tr>
                <td style='text-align:center;border:1px solid #000000;text-transform:uppercase;height:19px;font-weight:bold'>
                {{$pr->requestor_position}}
                </td>
            </tr>
            <tr>
                <td colspan='3' style='background-color:#000000;height:20px;'>
            </tr>
            <tr>
                <td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
                APPROPRIATION AVAILABLE
                </td>
                <td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
                FUNDS AVAILABLE
                </td>
                <td style='width:33%; font-weight:bold;text-align:left;border:1px solid #000000;'>
                APPROVED
                </td>
            </tr>
            <tr>
                <td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>

                </td>
                <td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>

                </td>
                <td style='border:1px solid #000000;height:25px;text-align:center;text-transform:uppercase;font-weight:bold;'>

                </td>
            </tr>
            <tr>
                <td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
                {{$aa->name}}<br/>
                {{$aa->position}}
                </td>
                <td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
                {{$c->name}}<br/>
                {{$c->position}}
                </td>
                <td style='width:33%; font-weight:bold;text-align:center;border:1px solid #000000;text-transform:uppercase;'>
                {{$approval->name}}<br/>
                {{$approval->position}}
                </td>
            </tr>
        </table>
    </div>
    <div class="row">
        <div style='float:left;font-weight:normal;font-style:italic;font-size:7pt;width:40%;text-align:left;'>{{$created_code}}</div>
    </div>
</div>

<div class="content" >
      <div class="row">
        <table style='width:100%;font-size:14px;text-align:center;border:1px solid #000000;' id='items'  cellpadding='0' cellspacing='0'>

            <thead>
                <tr>
                    <td style='width:7%;font-weight:bold;'>ITEM NO.</td>
                    <td style='width:7%;font-weight:bold;'>QTY</td>
                    <td style='width:7%;font-weight:bold;'>UNIT</td>
                    <td style='width:49%;font-weight:bold;'>DESCRIPTION</td>
                    <td style='width:15%;font-weight:bold;'>ESTIMATED UNIT OF</td>
                    <td style='width:15%;font-weight:bold;'>ESTIMATED COST</td>
                </tr>
            </thead>    

            <tbody >
                @foreach($list as $indexKey => $list)

                <tr>
                  <td>{{$indexKey}}</td>
                  <td>{{$list->pr_qty}}</td>
                  <td>{{$list->pr_unit}}</td>
                  <td>{{$list->pr_description}}</td>
                  <td  style='text-align: right;'>{{$list->pr_cost_per_unit}}</td>
                  <td style='text-align: right;'>{{$list->pr_estimated_cost}}</td>
                </tr>

                @if($indexKey >= 9)
                        @break
                @endif

                @endforeach

                @for($i = $count; $i < 10; $i++)
                    <tr><td>&nbsp;</td><td>&nbsp;</td>&nbsp;<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
                @endfor

            </tbody>

            <tfoot>
                <tr style="background-color: #b0b1b2;">
                  <td colspan="5" style="text-align: right; font-weight: bold;">GRAND TOTAL</td>
                  <td style="text-align: right; font-weight: bold;">
                    {{number_format($grand_total,2)}}
                  </td>
                </tr>
            </tfoot>
        </table>
      </div>
  </div>



</div>

<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
</body>
</html>

PDF
#项目tr{border:1px solid#000000;}
#项目tbody tr td{边框:1px实心#000000;}
#项目名称{背景色:#231F20;颜色:#FFFFFF;}
.header{位置:固定;左侧:0px;顶部:-40px;右侧:0px;}
.footer{位置:固定;左侧:0px;底部:200px;右侧:0px;}
{{$pr->pr_form_no}
菲律宾共和国
洛杉矶联合省
圣费尔南多市
PR

采购申请
部门: {{$dept->office_name}
第节: {{$section->office_name}}
公共关系编号。 {{$pr->pr_form_no} 赛:没有。 ObR编号。 日期 {{$dt->toFormattedDataTestRing()} 预算 PHP{{number_格式($pr->budget_alloc,2)} 供应商 {{$pr->供应商类型} 请求办公室 目的
{{$pr->目的} {{$pr->requestor_name} {{$pr->requestor_position} 可用拨款 可用资金 经核准的 {{$aa->name}}
{{$aa->position} {{$c->name}}
{{$c->position} {{$approval->name}}
{{$approval->position} {{$created_code}} 项目编号。 数量 单位 描述 估计单位 估计成本 @foreach($indexKey=>$list) {{$indexKey} {{$list->pr_数量} {{$list->pr_unit} {{$list->pr_description} {{$list->pr\u每单位成本} {{$list->pr_估计成本} @如果($indexKey>=9) @中断 @恩迪夫 @endforeach @对于($i=$count;$i<10;$i++) @结束 总计 {{number_格式($grand_total,2)}
当显示的项目已经是10时,我已经尝试使用刀片的中断功能来停止循环


*如果代码看起来像地狱一样,也很抱歉。

您可以使用一些css样式,如下所示:

<style>
.page-break {
 page-break-after: always;
}
</style>
  <h1>page</h1>
   <div class="page-break"></div>
  <h1>Someother Page</h1>

.分页符{
分页符后:始终;
}
页
另一页
如果要在例如5个div之后进行分页符,则可以执行以下操作:

@php $check=0 @endphp
@foreach($array as $item)
@php $check++ @endphp
  <!-- your code or something like divs -->
@if( $check % 5 == 0 ) 
     @php echo '<div class="page-break"></div>'; @endphp .... 
 @endif
@endforeach
@php$check=0@endphp
@foreach($数组作为$项)
@php$check++@endphp
@如果($check%5==0)
@php回声“”@endphp。。。。
@恩迪夫
@endforeach

希望你能从中得到启发

您可以使用一些css样式