Laravel — Create nice invoices with DomPDF (template!)

Dennis Smink
2 min readSep 3, 2018

So you have to create a basic but good looking invoice design for your client (or yourself) in PDF format?

The invoice design I will provide in this article

Chances are that you’re using the laravel-dompdf package from Barryvdh, if so; good. Because this tutorial assumes you are using this package, I have not tried it with the original DomPDF wrapper though.

In my experience designing and giving a nice structural form to invoice templates has always been a pain in DomPDF, this is why I want to share this template with you.

Don’t worry there are no fancy tricks involved, just a plain template which you can adjust to your needs. Get it right here:

I always render the PDF’s from a method inside the Order.php model:

public function getPdf($type = 'stream')
{
$pdf = app('dompdf.wrapper')->loadView('order-pdf', ['order' => $this]);

if ($type == 'stream') {
return $pdf->stream('invoice.pdf');
}

if ($type == 'download') {
return $pdf->download('invoice.pdf');
}
}
...

--

--