Mpdf example


            $mpdfConfig = array_replace_recursive(
                $defaultConfig,
                [
                    'margin_left' => $this->_document['left'],
                    'margin_right' => $this->_document['right'],
                    'margin_top' => $this->_document['top'],
                    'margin_bottom' => $this->_document['bottom'],
                ]
            );
            if ($this->_preview == true || !$this->_documentHash) {
                $mpdf = new Mpdf($mpdfConfig);
                $mpdf->setLogger(
                    Shopware()->Container()->get('corelogger')
                );
                $mpdf->WriteHTML($html);
                $mpdf->Output();
                exit;
            }

            $tmpFile = tempnam(sys_get_temp_dir(), 'document');
            $mpdf = new Mpdf($mpdfConfig);
            $mpdf->setLogger(
                
Shopware()->Template()->assign('config', [
            'sepaCompany' => Shopware()->Config()->get('sepaCompany'),
            'sepaHeaderText' => Shopware()->Config()->get('sepaHeaderText'),
            'sepaSellerId' => Shopware()->Config()->get('sepaSellerId'),
        ]);

        Shopware()->Template()->addTemplateDir(__DIR__ . '/../Views/');
        $data = Shopware()->Template()->fetch('frontend/plugins/sepa/email.tpl');

        /** @var array<string, string> $mpdfConfig */
        $mpdfConfig = Shopware()->Container()->getParameter('shopware.mpdf.defaultConfig');
        $mpdf = new Mpdf($mpdfConfig);
        $mpdf->WriteHTML($data);
        $pdfFileContent = $mpdf->Output('', 'S');

        if ($pdfFileContent === false) {
            throw new Enlight_Exception('Could not generate SEPA attachment file');
        }

        $attachmentName = 'SEPA_' . $orderNumber;

        $mail->createAttachment(
            $pdfFileContent,
            
Home | Imprint | This part of the site doesn't use cookies.