This package adds a quick and simple way to print and print-as-pdf your Filament resource tables or forms, pretty handy to add basic reports (a lot of times it would be enough), it works with a any kind of sort, search, filter or paginated or all data.
You can install the package via composer:
composer require arielmejiadev/filament-printable
You can publish and run the stubs:
php artisan filament-printable:install
// or
php artisan vendor:publish --tag="filament-printable-stubs"
// Add print button in a filament list header
class ListUsers extends ListRecords
{
protected function getHeaderActions(): array
{
return [
// ...
PrintAction::make(),
];
}
}
// Add print button in Filament CreateRecord or EditRecord class
class EditUser extends EditRecord
{
protected function getHeaderActions(): array
{
return [
// ...
\ArielMejiaDev\FilamentPrintable\Actions\PrintAction::make(),
];
}
}
// Add print button as a bulk action
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
\ArielMejiaDev\FilamentPrintable\Actions\PrintBulkAction::make(),
]),
]);
By default, filament-printable
set print styles to make tables look good no matter if table has been:
- Sorted
- Show Search Results
- Show Filter Results
- Show Paginated Results
- Show all results
The styles are easily to customize in public/css/filament-printable/filament-printable-styles.css
By default Filament adds some flexible grids to form elements, if you want to set explicitly specific distribution for elements to print documents.
You can use Filament Grid
and Section
elements to distribute elements inside a form:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Grid::make()->schema([
Forms\Components\TextInput::make('name'),
Forms\Components\TextInput::make('email'),
])->columns([
'xs' => 1,
'sm' => 2,
]),
Forms\Components\Section::make([
Forms\Components\TextInput::make('name'),
Forms\Components\TextInput::make('email'),
Forms\Components\TextInput::make('second_email'),
])->columns([
'xs' => 1,
'sm' => 3,
]),
]);
}
Important
For Letter and Legal paper sizes the Filament columns sm
size distribution would be the one used.
Filament Printable includes some css styles to print your resources that most of the time looks awesome,
but you can customize your print css to match your requirements, in public/css/filament-printable/filament-printable-styles.css
Here an example to remove some section styles to print:
.fi-section {
background-color: transparent !important;
box-shadow: none !important;
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.