При создании pdf с разрывом страницы до 3-й строки дизайн ломается. Вот мой код
<!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>
Это pdf-версия страницы 1
Это pdf страница 2
На странице 2 вторая строка движется вправо. Как это исправить?
Как насчет использования 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>
@endforeach