Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在pdf的不同页面中显示每个列表项_Php_Laravel - Fatal编程技术网

Php 在pdf的不同页面中显示每个列表项

Php 在pdf的不同页面中显示每个列表项,php,laravel,Php,Laravel,我有这个查询,我使用包“”以pdf格式显示结果: public function getRegistrationInfo($regID){ $registration = Registration::with('conference',Conference.registrationTypes','Conference.registrationTypes.participants') ->where('id',$regID)->first();

我有这个查询,我使用包“”以pdf格式显示结果:

public function getRegistrationInfo($regID){
    $registration = Registration::with('conference',Conference.registrationTypes','Conference.registrationTypes.participants')
            ->where('id',$regID)->first();

    $pdf = PDF::loadView('pdf.registration', compact('registration'));

    return $pdf->download('invoice.pdf');
}
在“pdf.registration”视图中,我有以下内容来显示查询结果:

@foreach($registration->conference->registrationTypes as $key=>$registrationType)

        <li>
            <span>show the registration ID here : {{$registration->id}}</span> <br>
            <span>Conference name {{$registration->conference->name}}</span><br>
            <span>Registration type: {{$registration->conference->registrationTypes[$key]['name']}}</span><br>
            <span> Participant: {{$registration->conference->registrationTypes[$key]
            ->participants[0]->name .' '.$registration->
            conference->registrationTypes[$key]->participants[0]->surname}}</span><br>
            <span>Price: {{$registration->conference->registrationTypes[$key]['price']}}</span><br>
        </li>

    @endforeach
@foreach($registration->conference->registrationTypes as$key=>$registrationType)
  • 在此处显示注册ID:{{$registration->ID}}
    会议名称{{$registration->Conference->name}}
    注册类型:{{$Registration->conference->registrationTypes[$key]['name']}}
    参与者:{{$registration->conference->registrationTypes[$key] ->参与者[0]->姓名。“。$registration-> 会议->注册类型[$key]->参与者[0]->姓氏}}
    价格:{{$registration->conference->registrationTypes[$key]['Price']}}
  • @endforeach

    当用户点击按钮下载pdf文件时,pdf文件就会被下载。目前,它返回2个结果、2个列表项,这两个列表项都显示在pdf的第一页上。但我想把每个列表项都放在一页pdf中。您知道如何实现这一点吗?

    您可以在页面中使用下面的html和css进行分页符-

    把下面的html放在任何你想分页符的地方

    <div class="breakNow"></div>
    

    在此之后,您的pdf也应该在下一页中包含内容。

    谢谢,但仍然与“@foreach($registration->conference->registrationTypes as$key=>$registrationType)
  • @endforeach”一起出现在同一页上。在同一页上添加css样式,如“div.breakNow”{内部分页符:避免;之后分页符:始终;}…很有效,谢谢!
    div.breakNow { page-break-inside:avoid; page-break-after:always; }