Problems using kartik-mpdf in yii2

0

I'm using Kartik's mpdf in yii2, but it does not work well for me, since showing the pdf for the first time shows me rare characters like these

% PDF-1.4% 3 0 obj < > / Contents 4 0 R > > endobj 4 0 obj < > stream x [ r 3 U $ U4 - * "ѹ r D K + Z d y \ ~ 70 р R E o A I 'c G_ _ & Ǒ d ϧ n " e ѿ Fv cGo ge ׋ # - 3 # 3 wͤ \ 9 n ɍ { > ci- Z% k g. ZK gi Q 섙 f ^ ӖOv

If I update the page then I get the PDF right

What will be the problem? How do I get it right from the first time?

This is the code I use:

public function actionImprimepdf() {         
    $periodo = Periodoactivo::find()->one();
    $empresa = Empresa::find()->one();
    $modelo = VFacturacion::find()->where('Mes = :mes and Anno = :anno',[':mes' => $periodo->Mes, ':anno' => $periodo->Anno])->all();

    $content = $this->renderPartial('imprimepdf', ['modelo' => $modelo, 'empresa' => $empresa,]);

    $pdf = new Pdf([
        'mode' => Pdf::MODE_UTF8,
        'destination' => Pdf::DEST_DOWNLOAD,
        'filename' => 'pdf/Facturas.pdf',
        'content' => $content,
        'cssFile' => 'css/printfactura.css',
        'options' => ['title' => 'Facturas'],
        'methods' => [
           // 'SetHeader'=>['Krajee Report Header'],
           // 'SetFooter'=>['{PAGENO}'],
        ]
    ]);
    // return the pdf output as per the destination setting
    Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
    Yii::$app->response->headers->add('Content-Type', 'application/pdf');

    return $pdf->render();
}
    
asked by José A. Cáceres 05.11.2018 в 22:32
source

0 answers