1. Go to this page and download the library: Download kukux/pdf-template-builder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kukux / pdf-template-builder example snippets
use Kukux\PdfTemplateBuilder\PdfTemplateBuilderPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...your existing config...
->plugin(
PdfTemplateBuilderPlugin::make()
);
}
use Kukux\PdfTemplateBuilder\Filament\Actions\GeneratePdfAction;
protected function getHeaderActions(): array
{
return [
GeneratePdfAction::make()
->template('invoice-default'), // by template name
];
}
use Kukux\PdfTemplateBuilder\Filament\Actions\GeneratePdfTableAction;
->actions([
GeneratePdfTableAction::make()
->template(1), // by template id
])
use Kukux\PdfTemplateBuilder\Models\PdfTemplate;
$template = PdfTemplate::where('name', 'invoice-default')->firstOrFail();
$invoice = Invoice::find(42);
// Get the response (PDF if dompdf is installed, else HTML)
return $template->stream($invoice);
// Or just the rendered HTML:
$html = $template->render($invoice);
use Kukux\PdfTemplateBuilder\Rendering\Engines\FpdiEngine;
PdfTemplateBuilderPlugin::make()->engine(FpdiEngine::class)