我正在使用domppdf生成pdf文件,这是我的html和css for pdf layout:
<html>
<head>
<style type="text/css">
.boxtest{
height: 90px;
width: 270px;
background: #AAA;
font-size: 48px;
font-style: oblique;
color: #999;
text-align: center;
margin-top: 20px;
margin-left: 5px;
}
table
{
width: 100%;
}
th
{
background-color: #BBB;
height: 50px;
}
td
{
text-align: center;
}
/*tr:hover {background-color: #f5f5f5}*/
tr:nth-child(even)
{
background-color: #f2f2f2;border:4px solid #73AD21;
}
tr
{
border:4px solid #73AD21
}
.table-title
{
background-color: #EEE;
position:fixed;
top:0em;
}
.table-content-
{
position:fixed;
top:2.5em;
font-style: sans-serif;
}
h3, div
{
font-family: sans-serif;
}
.company-logo
{
position: absolute;
float:left;
margin-left: 1em;
top:0;
left:1em;
}
.cover-text
{
position:absolute;
top:7em;
margin: 8em 4em 4em;
text-align: justify;
page-break-after: always;
}
.footer
{
width:100%;
position:fixed;
bottom:37px;
text-align: center;
font-size: 13px;
}
.page_number
{
width:100%;
position:fixed;
bottom:17px;
text-align: center;
font-size: 11px;
}
.page_breaking
{
position:absolute;
bottom: 0px;
page-break-after: always;
}
.page_number:before { content: counter(page); }
@page
{
margin:0;
padding: 0;
}
</style>
</head>
<body>
<div class="footer" align="center" style="font-family: sans-serif;"> Powered by Hyosoka Poipo, 2016 </div>
<div class="page_number"></div>
<div style="background-color: #353535; max-width:200%; margin:0; padding:0" >
<div style="color: white; margin-top:20px; margin-bottom: 20px;">
<div align="center"><img src="img/ / -logo.png" alt=" Logo"/></div>
<div align="center"><h3 > {{$Title}} </h3> </div>
<div align="center"><h3><?php echo date("M-d, Y"); ?> </h3></div>
</div>
</div>
<div class="cover-text row" align="left">
<p> COVER TEXT </p>
{{$CoverText}}
</div>
<div class="table-title" align="center" style="font-size:34px;">
TABLE OF REPORT
</div>
<table class="table table-condensed table-bordered table-hover table-content- ">
<thead>
<tr>
<th>No</th>
<th>Candidate</th>
<th>Rating</th>
@if($Comment != "false")<th>Comment</th>@endif
@if($Num == 99)<th>Status</th>@endif
</tr>
</thead>
<tbody>
<?php $number = 1 ?>
@foreach($H as $candi)
<tr >
<td><?php echo $number++ ?></td>
<td style="text-align:left;"><b>{{$candi->fullname}}</b><br><div style="font-size:13px">{{$candi->phone}} {{$candi->email}}<br>{{$candi->location}}</div></td>
<td>{{$candi->rating}}</td>
@if($Comment != "false" )<td><div>{{$candi->comment}}</div></td>@endif
@if($Num == 99)<td><div>{{RHelper::Type($candi->status)}}</div></td>@endif
</tr>
{{-- The problem is in here... If the loop is big, then dompdf just generate 1 page and forget the rest of the loop --}}
@endforeach
</tbody>
</table>
</body>
</html>
问题在于循环,如果我有很多数据,dompdf只为我生成1页,如下所示:
那么......我如何在dompdf中自动创建一个新页面,以显示我的循环中的所有可用数据。我试图在我的html
结束时添加下面的代码.page_breaking
{
position:absolute;
bottom: 0px;
page-break-after: always;
}
{{-- <div class="page_breaking"></div> --}}
这对我不起作用,因为在页面中,循环从头开始。而且我也试图把
style="page-break-after: always;"
当索引达到特定值时,但这对我也不起作用,因为请求变为超时。那么还有什么方法可以尝试吗? 提前致谢
答案 0 :(得分:0)
问题在于您使用以下CSS为表格设置样式:
.table-content-
{
position:fixed;
top:2.5em;
font-style: sans-serif;
}
Dompdf不会分页固定或绝对定位的内容。当前定位的内容呈现如下:
删除桌面上的位置,它应该正常页面。