Dompdf example

public function __construct(private array $dompdfOptions)
    {
    }

    public function getContentType(): string
    {
        return self::FILE_CONTENT_TYPE;
    }

    public function render(RenderedDocument $document): string
    {
        $dompdf = new Dompdf();

        $options = new Options($this->dompdfOptions);

        $dompdf->setOptions($options);
        $dompdf->setPaper($document->getPageSize()$document->getPageOrientation());
        $dompdf->loadHtml($document->getHtml());

        /* * Dompdf creates and destroys a lot of objects. The garbage collector slows the process down by ~50% for * PHP <7.3 and still some ms for 7.4 */
        
Home | Imprint | This part of the site doesn't use cookies.