© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
63 replies
Vishal Thakkar

How to get selected records in PDF using filament 3

if there are 100 records from that few selected records pdf i need how to make that possible in filament 3
Solution
try this:



Tables\Actions\BulkAction::make('generatePdf')
                    ->label('Generate PDF')
                    ->action(function ($records) {
                        $pdf = Pdf::loadView('pdf.selected-items', ['records' => $records]);
                        return response()->streamDownload(function () use ($pdf) {
                            echo $pdf->output();
                        }, 'selected-items.pdf');
                    })
                    ->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('generatePdf')
                    ->label('Generate PDF')
                    ->action(function ($records) {
                        $pdf = Pdf::loadView('pdf.selected-items', ['records' => $records]);
                        return response()->streamDownload(function () use ($pdf) {
                            echo $pdf->output();
                        }, 'selected-items.pdf');
                    })
                    ->deselectRecordsAfterCompletion(),


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Selected Items</title>
    <style>
        /* Add any necessary styles here */
    </style>
</head>

<body>
    <h1>Selected Items</h1>
    @foreach ($records as $record)
        <h2>Item {{ $loop->iteration }}</h2>

        <p>ID: {{ $record->id }}</p>
        <p>Name: {{ $record->name }}</p>
        
    @endforeach
</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Selected Items</title>
    <style>
        /* Add any necessary styles here */
    </style>
</head>

<body>
    <h1>Selected Items</h1>
    @foreach ($records as $record)
        <h2>Item {{ $loop->iteration }}</h2>

        <p>ID: {{ $record->id }}</p>
        <p>Name: {{ $record->name }}</p>
        
    @endforeach
</body>

</html>


with this you dont have to use controller
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
Next page

Similar Threads

How to Access Selected Records in a BulkAction::visible() in Filament?
FilamentFFilament / ❓┊help
4mo ago
How to set the default selected records in the filament table?
FilamentFFilament / ❓┊help
14mo ago
How to get selected records on table from livewire
FilamentFFilament / ❓┊help
2mo ago
Selected records to widget
FilamentFFilament / ❓┊help
2y ago