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

fabiobettiol's avatar

Nova Action: export resource to a customized PDF

Interested in streaming to PDF (not download, and preferable on a new tab) a customized version (with barcode, etc) of the resource, using barryvdh/laralev-dompdf

It works if I follow the samples, by using a controller in laravel. How to achieve it from a Nova Action, as Action:download does not appear to accept streams... ?.

Any light to follow on this ?

Thanks!

0 likes
6 replies
fabiobettiol's avatar

Thank you vandan.

I already followed those paths, without answers.

Even laravel-excel includes an option to export as PDF, I don't want a PDF version of a list of models, but instead, an individual PDF for each model (record), such like an invoice for an individual order.

I'm using nova 2.0. The documentation includes instructions for downloading responses (https://nova.laravel.com/docs/2.0/actions/defining-actions.html#action-responses), but those are for existing- file responses, not for streamed (PDF) output.

barryvdh's $pdf->download() and $pdf->stream() don't appear to work neither used from the action's handle method, nor from a controller (and view) that is being called from the handle method with (new InvoicePDF)->printInvoice().

Conclussion, I'm stuck.

hungit's avatar

@fabiobettiol You can use Action::redirect() to redirect to another route where you export PDF actually. Hope this help.

1 like
Torpedo's avatar

@FABIOBETTIOL - you can just open the created pdf in a new tab, no need for a extra route for it..

i did it like this:

        $invoicePDF = new PdfPrintController();
    $invoice_nr = Invoice::max('invoice_number');
        $path = $invoicePDF->makePDF($model);

    return Action::openInNewTab(url($path),'Rechn-'.$invoice_nr.'.pdf');

1 like
kidereo's avatar

Hi, I know this is an oldish thread but have you managed to solve the problem it in the end?

I am trying to create a pdf file in an Event listener and have the same problem. The pdf file is created fine through the controller but not through the listener's handle. Any suggestion would be much appreciated!

1 like

Please or to participate in this conversation.