yii2tech / html2pdf

Yii2 component for HTML to PDF conversion
Other
78 stars 65 forks source link

fix fontDir param for Mpdf 7.x #18

Closed lutek closed 5 years ago

lutek commented 5 years ago

https://github.com/yii2tech/html2pdf/issues/17

lutek commented 5 years ago

with fix work fine:

        $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
        $fontData = $defaultFontConfig['fontdata'];

        $path = Yii::getAlias('@app/data/pdf/');
        $targetFile = $path . $model->qr_key . '.pdf';

        $options = [
            'fontDir' => '@app/data/fonts/',
            'fontdata' => $fontData + [
                    'Roboto' => [
                        'R' => 'Roboto-Regular.ttf',
                        'I' => 'Roboto-Italic.ttf',
                        'B' => 'Roboto-Bold.ttf',
                    ]
                ],
            'default_font' => 'Roboto',
        ];

        Yii::$app->html2pdf
            ->convert($html, $options)
            ->saveAs($targetFile);
klimov-paul commented 5 years ago

Resolved by commit c68115bfc4016cd4bc287037bfd17d9526100dce