I am trying to get PDF using DomPDF but I come cross a strange problem. All the data and other things are fine but when it renders in PDF the first line of the table is always out of style. Firstly, I though may be table is going to the next page which cause style out of context but I tried to limit table to one page and found out that the problem still exists. So, the first row of table on every page goes crazy. Following is my code and screen shots of PDF.
我试图使用DomPDF获取PDF但我遇到了一个奇怪的问题。所有数据和其他东西都很好但是当它以PDF格式呈现时,表格的第一行总是不合时宜。首先,我可能是桌子会进入下一页导致样式脱离上下文但我试图将表限制为一页,并发现问题仍然存在。所以,每一页上的第一行表都很疯狂。以下是我的PDF代码和屏幕截图。
Controller
调节器
$dompdf = new DOMPDF();
$dompdf->load_html($listing);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
$dompdf->stream("sample.pdf");
View
视图
<table class="table table-bordered">
<tr>
<th width="150">Client </th>
<td>Client Name </td>
</tr>
<tr>
<th>Site </th>
<td><?php print $site->title; ?></td>
</tr>
<tr>
<th>Address </th>
<td>
<?php
print $site->unit.' '.
$site->street.' '.
$site->suburb.' '.
$site->state.' '.
$site->location;
?>
</td>
</tr>
<tr>
<th>Post Code </th>
<td><?php print $site->postcode; ?></td>
</tr>
<tr>
<th colspan="2"> Site Information</th>
</tr>
<tr>
<td colspan="2" height="150"> <?php print $site->site_information; ?></td>
</tr>
<tr>
<th colspan="2">Work Instruction</th>
</tr>
<tr>
<td colspan="2" height="200"> <?php print $site->work_instruction; ?></td>
</tr>
<tr>
<th colspan="2">Equipment on Site</th>
</tr>
<tr>
<td colspan="2"> <?php print $site->site_equipment; ?></td>
</tr>
<tr>
<th colspan="2">Special Instructions</th>
</tr>
<tr>
<td colspan="2" height="100"> <?php print $site->special_instruction; ?></td>
</tr>
<tr>
<th>Contact Person </th>
<td><?php print $site->contact_person; ?></td>
</tr>
<tr>
<th>Contact Number </th>
<td><?php print $site->contact_no; ?></td>
</tr>
</table>
Page 1:
第1页:
Page 2:
第2页:
Any help will be highly appreciated. Thanks
任何帮助将受到高度赞赏。谢谢
19
I use
我用
thead:before, thead:after { display: none; }
tbody:before, tbody:after { display: none; }
9
Almost certainly the issue is your use of Bootstrap. A lot of dompdf issues related to Bootstrap have to do with the :before
/:after
declarations. I think you can work around the problem in this particular case by applying the following CSS for dompdf:
几乎可以肯定,问题是你使用Bootstrap。很多与Bootstrap相关的dompdf问题都与:before /:after声明有关。我认为你可以通过对dompdf应用以下CSS来解决这个特定情况下的问题:
tbody:before, tbody:after { display: none; }
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2015/04/13/7da5d98b14ab252af67c4cfc63e73861.html。