Zum Inhalt springen

API reference / Quittio \ Core \ Pdf

LogoCache

final readonly class in quittio/core

Quittio\Core\Pdf\LogoCache · Source

Prepares logos for the PDF and caches the result.

mPDF never fetches a logo itself: remote images (http and https only) are downloaded by RemoteImageFetcher from public hosts and cached as local files; other stream wrappers are refused. Logos may be local files (configuration), data URIs or such URLs.

Without PDF/A, large raster files are scaled once to the size used in the PDF; SVG must be self-contained. For PDF/A (ZUGFeRD/Factur-X), which allows neither the alpha channel mPDF would write nor mPDF's SVG output (ISO 19005-3, 6.2.2), every logo is re-encoded as RGB PNG on white: raster images are flattened, SVG is rasterised with Imagick.

Methods#

MethodDescription
->__construct()
->resolve()A value for the renderer that can never trigger a server-side request: a local file ({@see realpath()}) for existing files, or a canonical data URI built from bytes this class has decoded and checked itself (for http(s) URLs and data URIs). Null if a remote logo cannot be downloaded. Everything else is refused.

__construct()#

public function __construct(
    string $directory,
    int $maxWidth = 600,
    int $maxHeight = 200,
    bool $pdfa = false,
    ?RemoteImageFetcher $fetcher = null,
)
ParameterTypeDescription
$directorystring
$maxWidthint = 600
$maxHeightint = 200
$pdfabool = false
$fetcher?RemoteImageFetcher = null

resolve()#

public function resolve(?string $logo): ?string

A value for the renderer that can never trigger a server-side request: a local file ({@see realpath()}) for existing files, or a canonical data URI built from bytes this class has decoded and checked itself (for http(s) URLs and data URIs). Null if a remote logo cannot be downloaded. Everything else is refused.

ParameterTypeDescription
$logo?string
Returns
?string

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.