I am using dompdf version 0.8.3 in all our reports, we have done the adding header and footer in each page. Now we want to have margin-top in each page of our header because our header overlapped to our table.
<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>
Controller
<!-- 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');
Question: Is it possible to have a margins(margin-top to be specific in each page) and to skip the 1st page to have header and page number?
Inside your pdf blade file, you can use css styles. For margins, try this something like this, and edit numbers for your preference:
<style>
@page {
margin: 2cm 2cm 1.5cm 1.5cm;
}
</style>
As for page brakes, I'm not sure exactly what do you want to achieve, but you can add page breaks inside the same pdf blade like this:
<div class="page-break"></div>
Hope that this can lead you in right direction.