当生成pdf时,在第3行之后使用page-break-pdf,设计被分解了。以下是我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<title>DOM-PDF</title>
</head>
<body>
<table style="width:100%;">
<thead>
<tr>
<th>Serial</th>
<th>Name</th>
<th>Roll</th>
<th>Info</th>
</tr>
</thead>
<tbody>
@php
$n = 0;
for($i=0;$i<10;$i++){
@endphp
<tr style="text-align:center;">
<td>1</td>
<td>Rashedul Hasan</td>
<td>1208039</td>
<td>I am an employee.</td>
</tr>
@php
if($n==3){
echo "<i style='page-break-before:always;'></i> ";
}
$n++;
}
@endphp
</tbody>
</table>
</body>
</html>这是第1页的pdf视图

这是第2页的pdf视图

在第二页,第二行向右移动。如何修复它?
发布于 2020-12-24 22:54:55
如果使用chunks而不是打破常规呢?
{{-- Replace collect()->times(10) with a collection when you're getting the actual data from DB --}}
@foreach (collect()->times(10)->chunk(3) as $chunk)
<table style="width:100%;">
<thead>
<tr>
<th>Serial</th>
<th>Name</th>
<th>Roll</th>
<th>Info</th>
</tr>
</thead>
<tbody>
@foreach($chunk as $result)
<tr style="text-align:center;">
<td>{{ $result }}</td>
<td>Rashedul Hasan</td>
<td>1208039</td>
<td>I am an employee.</td>
</tr>
@endforeach
</tbody>
</table>
<i style='page-break-before:always;'></i>
@endforeachhttps://stackoverflow.com/questions/65439799
复制相似问题