© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
22 replies
Prosp30

Download PDF using Spatie Laravel-PDF on table action

I am trying to download a PDF generated from a blade view. I tried DOMPDF and it works fine, but I would like to use Spatie's PDF which has better funcionality. I added the PDF to the table action, but the button just spins and nothing gets returned. Is there a way to convert the PDF to a stream to make it downloadable or?

Action::make('download')
                    ->action(function (Invoice $record) 
                        {
                            return pdf()->view('pdf.invoice', ['invoice' => $record])
                                ->format('a4')
                                ->name('your-invoice.pdf')
                                ->download();
                        })
                    ->iconButton('heroicon-o-document-arrow-down')
                    ->icon('heroicon-o-document-arrow-down')
                    ->label('Preuzmi PDF'),
Action::make('download')
                    ->action(function (Invoice $record) 
                        {
                            return pdf()->view('pdf.invoice', ['invoice' => $record])
                                ->format('a4')
                                ->name('your-invoice.pdf')
                                ->download();
                        })
                    ->iconButton('heroicon-o-document-arrow-down')
                    ->icon('heroicon-o-document-arrow-down')
                    ->label('Preuzmi PDF'),
Solution
I managed to do it

return response()->streamDownload(function () use ($record) {
                                echo base64_decode(Pdf::view('pdf.invoice', ['invoice' => $record])
                                    ->format('a4')
                                    ->footerView('pdf.invoicefooter')
                                    ->name('your-invoice.pdf')
                                    ->base64());
                            }, 'test' . '.pdf');
return response()->streamDownload(function () use ($record) {
                                echo base64_decode(Pdf::view('pdf.invoice', ['invoice' => $record])
                                    ->format('a4')
                                    ->footerView('pdf.invoicefooter')
                                    ->name('your-invoice.pdf')
                                    ->base64());
                            }, 'test' . '.pdf');
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Can't download PDF using Spatie Laravel-pdf
FilamentFFilament / ❓┊help
11mo ago
Spatie laravel-translatable
FilamentFFilament / ❓┊help
15mo ago
Table column download spatie document file
FilamentFFilament / ❓┊help
2y ago
Spatie Translatable with spatie laravel settings
FilamentFFilament / ❓┊help
15mo ago