Skip to content

API reference / Quittio \ Core \ Pdf \ Renderers

FagusRenderer

final class in quittio/core · implements PdfRenderer

Quittio\Core\Pdf\Renderers\FagusRenderer · Source

Optional renderer: HTML/CSS to PDF/A-3b with Fagus (package nforst/fagus), an engine for CSS Paged Media that runs as a binary next to PHP.

Templates stay written for mPDF: their mPDF markup (page headers and footers, page breaks, named pages, positioned elements, watermark, carry-over rows) is translated into standard CSS before rendering (MpdfMarkupConverter). The fonts are the same as for MpdfRenderer: the mPDF family names (geist, geistmedium, inter, liberationsans and those of $fonts) map to the font files. PDF/A, the embedded XML and its Factur-X metadata are written by Fagus.

Like mPDF, Fagus never loads anything over the network. It reads no files by itself either: only images that the HTML names by a local path (the logo prepared by LogoCache) are handed over, and only if they are images.

Methods#

MethodDescription
->__construct()
->render()Renders the HTML with Fagus and returns the PDF; with $request->pdfa as PDF/A-3b, with the embedded XML as ZUGFeRD/Factur-X (PDF/A-3b, the profile from the conformance level). Throws a PdfException when Fagus fails.
->supportsEmbedding()

__construct()#

public function __construct(
    array<string, array<string, string>> $fonts = [],
    list<string> $fontDirectories = [],
    string $defaultFont = 'geist',
    ?string $binary = null,
    float $timeout = 60.0,
)
ParameterTypeDescription
$fontsarray<string, array<string, string>> = []additional fonts: family => [R => file, B => file, I => file, BI => file]
$fontDirectorieslist<string> = []searched first, before the bundled Geist, Inter and Liberation Sans; directories that do not exist are skipped
$defaultFontstring = 'geist'
$binary?string = nullpath of the fagus binary; null = FAGUS_BINARY, the binary installed with the package or fagus on the PATH
$timeoutfloat = 60.0seconds to wait for each answer of the Fagus worker

render()#

public function render(RenderRequest $request): string

Renders the HTML with Fagus and returns the PDF; with $request->pdfa as PDF/A-3b, with the embedded XML as ZUGFeRD/Factur-X (PDF/A-3b, the profile from the conformance level). Throws a PdfException when Fagus fails.

ParameterTypeDescription
$requestRenderRequest
Returns
string

supportsEmbedding()#

public function supportsEmbedding(): bool
Returns
bool

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.