arielmejiadev / filament-printable
Package to get your Filament Resources Printable
Fund package maintenance!
ArielMejiaDev
Requires
- php: ^8.1|^8.2
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
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.
Installation
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"
Usage
// 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(), ]), ]);
Print Filament Tables
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
Print Filament Forms
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.
Customization
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; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.