surda / pdf
PDF bulder
v2.0.0
2021-04-03 18:56 UTC
Requires
- php: >=8.0
- latte/latte: ^2.10
- mpdf/mpdf: ^8.0
- nette/application: ^3.1
- nette/di: ^3.0
Requires (Dev)
- nette/tester: ^2.0
- ninjify/nunjuck: ^0.3
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-nette: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
This package is auto-updated.
Last update: 2024-10-29 05:28:48 UTC
README
Installation
The recommended way to is via Composer:
composer require surda/pdf
After that you have to register extension in config.neon:
extensions: pdf: Surda\Pdf\DI\PdfExtension
Configuration
Default
pdf: template: defaults: layout: @@default config: layout: @@default
Usage
Builder
/** @var Surda\Pdf\IPdfBuilderFactory @inject */ public $pdfBuilderFactory;
// Builder $builder = $this->pdfBuilderFactory->create(); // Template $builder->setTemplateFile(__DIR__ . '/path/to/template.latte'); $builder->setParameters([ 'foo' => 'World!', ]); // Get Mpdf $mpdf = $builder->getMpdf(); $this->sendResponse(new PdfResponse($mpdf->Output('file.pdf', \MPdf\Output\Destination::DOWNLOAD)));
Template
Each template has many internal variables:
$_defaults
- refer default configuration$_config
- refer custom configuration
{layout defaults->layout}
{block #content}
Hello, {$foo}
{/block}