filename(), orientation(), margins()), allowing adaptation to non-standard use cases (e.g., multi-page layouts, dynamic content).composer require + action registration). Minimal boilerplate for core functionality.content() method).!important overrides).wkhtmltopdf installed (common pain point in shared hosting).max_execution_time and memory_limit).filament/filament version.TableActions vs. ResourceActions).filename() input to prevent directory traversal (e.g., ../malicious.pdf).wkhtmltopdf installation)?InvoiceResource for exporting invoices.use Torgodly\Html2Media\Actions\Html2MediaAction;
public static function getTableActions(): array
{
return [
Html2MediaAction::make('exportPdf')
->filename(fn (Invoice $record) => "invoice_{$record->id}.pdf")
->content(fn (Invoice $record) => view('invoices.pdf_template', ['invoice' => $record])),
];
}
Dompdf calls) with the package.$this->app->singleton(Html2MediaConfig::class, fn () => new Html2MediaConfig([
'default_options' => [
'orientation' => 'portrait',
'margin_top' => 20,
'margin_bottom' => 20,
],
]));
composer.json for exact range).file_get_contents, dom, and mbstring are enabled.wkhtmltopdf is installed and in PATH.composer require torgodly/html2media.php artisan vendor:publish --tag=html2media-config.wkhtmltopdf (if using SnappyPDF):
# Ubuntu/Debian
sudo apt-get install wkhtmltopdf
# Or download from https://wkhtmltopdf.org/
->content('<h1>Test</h1>')).->content(fn ($record) => view('emails.template', ['data' => $record->toArray()]))
wkhtmltopdf) and set up alerts.wkhtmltopdf updates may require reconfiguration.position: fixed).wkhtmltopdf or PHP extensions.How can I help you explore Laravel packages today?