Laravel 5:DOMPDF(0.8.3) 在每页中设置顶部边距



我在我们所有的报告中都使用了dompdf版本0.8.3,我们已经在每个页面中添加了页眉和页脚。现在我们希望在页眉的每一页都有边距顶部,因为我们的页眉与我们的表格重叠。

.PDF

<script type="text/php">
if (isset($pdf)) {
$x = 550;
$y = 800;
$text = "{PAGE_NUM} of {PAGE_COUNT}";
$font = null;
$size = 12;
$color = array(255,0,0);
$word_space = 0.0;  //  default
$char_space = 0.0;  //  default
$angle = 0.0;   //  default
// header
$pdf->page_text(550,10,'P O #: <?= $purchase_order->number ?>',$font,$size,$color,$word_space,$char_space,$angle);
// footer
$pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
}
</script>

控制器

<!-- My other function/data -->
$pdf = PDF::loadView('purchase-order.export.export-pdf', $data)->setPaper('a4');
$pdf->getDomPDF()->set_option("enable_php", true);
return $pdf->stream('purchase-order-'.$purchase_order->number.'.pdf');

问题:是否可以有一个边距(每页中特定的边距顶部(并跳过第一页以获得页眉和页码?

在 pdf 刀片文件中,可以使用 css 样式。对于边距,请尝试如下操作,并根据自己的喜好编辑数字:

<style>
@page  {
margin: 2cm 2cm 1.5cm 1.5cm;
}
</style>

至于页面制动器,我不确定您想要实现什么,但您可以在同一个 pdf 边栏选项卡中添加分页符,如下所示:

<div class="page-break"></div>

希望这能引导你走向正确的方向。

最新更新