Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marin246's avatar

Laravel Cashier Invoice: A4 format

Hi, how can i change the paper format of an invoice generated by Cashier to A4?

I found the following relevant code in the Cashier package but I can't figure out, how I am supposed to do customizations with it:

public function pdf(array $data)
{
        if (! defined('DOMPDF_ENABLE_AUTOLOAD')) {
            define('DOMPDF_ENABLE_AUTOLOAD', false);
        }

        if (file_exists($configPath = base_path().'/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
            require_once $configPath;
        }

        $dompdf = new Dompdf;

        $dompdf->loadHtml($this->view($data)->render());

        $dompdf->render();

        return $dompdf->output();
}

Thanks very much in advance for any help, Simon

0 likes
8 replies
marin246's avatar

Yes, of course, that is an obvious solution, but is there a way to do it without changing the Cashier code?

mikevrind's avatar

Isn't there any configuration file available to edit?

marin246's avatar

Well, I don't know for sure. I haven't found anything in the docs and the referenced $configPath = base_path().'/vendor/dompdf/dompdf/dompdf_config.inc.php'file doesn't exist. (and I don't know how it could be used to change the paper format even if I created it.)

Mittler's avatar

Same Problem. Did you found any solution?

Mittler's avatar

I made a provisional workaround. I've created a class that extends Laravel\Cashier\Invoice and overrides the function pdf(array $data). In the controller, I use $model->findInvoiceOrFail($invoice_id) instead of $model->downloadInvoice($invoice_id, array $data). I then cast the returned instance to my custom class and then call download(). This is far from optimal, but works for now.

I would be very happy if someone could give me a better solution.

Please or to participate in this conversation.