Could you please help me? I am desperate and I have been a few days since I entered the world of Yii, and over these weeks I have run into many mistakes which make it difficult for me to work.
One of that for now I need to resolve is linked to the creation of pdf using mpdf.
I have already tried everything possible, and everything always ends in errors … one of them and the one that is causing me problems at the moment is:
"Fatal error: Trait 'Mpdf \ Strict' not found in C: \ xampp \ htdocs \ pdf2 \ protected \ vendor \ mpdf \ Mpdf.php on line 39"
I do not really understand why this error jumps me, and the truth very few ask about this error, and the truth is if I need someone at least to guide me in why this happens.
Next I leave the code that I am using for the creation of the pdf:
main.php:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf'=> array(
'librarySourcePath' => 'application.vendor.mpdf.*',
'constants'=> array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
/*'defaultParams' => array( // More info: http://mpdf1.com/manual/index.php?tid=184
'mode' => '', // This parameter specifies the mode of the new document.
'format' => 'A4', // format A4, A5, ...
'default_font_size' => 0, // Sets the default document font size in points (pt)
'default_font' => '', // Sets the default font-family for the new document.
'mgl' => 15, // margin_left. Sets the page margins for the new document.
'mgr' => 15, // margin_right
'mgt' => 16, // margin_top
'mgb' => 16, // margin_bottom
'mgh' => 9, // margin_header
'mgf' => 9, // margin_footer
'orientation' => 'P', // landscape or portrait orientation
)*/
)
)),
DatosController.php: (the table of my db)
public function actionPdf($id)
{
$model=$this->loadModel($id);
$mPDF1 = Yii::app()->ePdf->mpdf('utf-8','A4','','',15,15,35,25,9,9,'P');
$mPDF1->useOnlyCoreFonts = true;
$mPDF1->SetTitle("xxxxxxxxxx - Reporte");
$mPDF1->SetAuthor("");
$mPDF1->watermark_font = 'DejaVuSansCondensed';
$mPDF1->watermarkTextAlpha = 0.1;
$mPDF1->SetDisplayMode('fullpage');
$mPDF1->WriteHTML($this->renderPartial('pdf',array(
'model'=>$this->loadModel($id),
),true));
$mPDF1->Output('Reporte_'.date('YmdHis'),'I');
exit;
}
in the AccesRule i have this:
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete','create','update', 'index','view','Pdf', 'GenerarPdf'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
the rest of the code I used was to create a button that generates the pdf, that I did in the admin of the view of the table of my db, and an html file where the structure of the pdf to create is.
Please help, this is urgent, if someone in this forum can give me your support, I will thank you very much.
I clarify that the version of Yii that I am using is 1.1.6, and that of mpdf is 8.0.0