Php 在pdf的不同页面中显示每个列表项
我有这个查询,我使用包“”以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();
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)
div.breakNow { page-break-inside:avoid; page-break-after:always; }