Skip to content
PDF builder into Nette Framework
PHP HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources/layouts
src
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpstan.neon

README.md

PDF builder into Nette Framework


Build Status Licence Latest stable PHPStan

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}
You can’t perform that action at this time.