I have an action to make a pdf and display it, the only thing I need is to give it a signature but I have not been able to change the font family in any way, at least not with renderpartial
My code
`public function actionGenerarPdf($id)
{
$model = Persona::findOne([‘id’ => $id]); // Asegúrate de tener esta función en tu controlador para encontrar el modelo por su ID.
$searchModel = new DocumentoadjuntoSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, 1, $model->id, 'Persona');
// Buscar información laboral del usuario
$informacionLaboralModel = Informacionlaboral::findAll(['idPersona' => $model->id]);
// Buscar información de estudio del usuario
$informacionEstudioModel = Informacionestudio::findAll(['idPersona' => $model->id]);
// Buscar información de oficios
$informacionOficiosModel = Informacionoficios::findAll(['idPersona' => $model->id]);
$content = $this->renderPartial('print', [
'model' => $model,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'informacionLaboralModel' => $informacionLaboralModel,
'informacionEstudioModel' => $informacionEstudioModel,
'informacionOficiosModel' => $informacionOficiosModel,
]);
$pdf = new Pdf([
// set to use UTF8 encode only
'mode' => Pdf::MODE_UTF8,
// A4 paper format
'format' => Pdf::FORMAT_A4,
// portrait orientation
'orientation' => Pdf::ORIENT_PORTRAIT,
'filename' => 'Hoja de vida ' . $model->primerNombre . date("d M Y"),
'content' => $content,
'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
// 'cssInline' => '.firma{font-family: Pacifico, cursive; color:red;}',
'cssInline' => '
#firma{
font-family: "Pacifico", cursive !important;
font-size:44px !important;
color:#ffff !important,
}',
'options' => ['title' => 'Krajee Report Title'],
'methods' => [
'SetTitle' => 'Hoja de vida',
'SetSubject' => 'Generating PDF : ' . $model->primerNombre,
'SetHeader' => ['Hoja de vida ||Generado el: ' . date("d M Y")],
'SetFooter' => ['|Pagina {PAGENO}|'],
'SetAuthor' => $model->primerNombre,
'SetCreator' => $model->primerNombre,
'SetKeywords' => 'Krajee, Yii2, Export, PDF, MPDF, Output, Privacy, Policy, yii2-mpdf',
// 'SetFooter' => [
// '<i style="font-family: Pacifico, cursive;">Firma: ' . $model->primerNombre . '</i>'
// ],
'SetFooter' => ['<i style="text-align:end; font-weight:blod; font-family:"Pacifico"; font-size:25px; font-style: italic;">' . $model->primerNombre . '</i>'],
]
]);
return $pdf->render();
// return $this->render('print', [
// 'model' => $model,
// 'searchModel' => $searchModel,
// 'dataProvider' => $dataProvider,
// 'informacionLaboralModel' => $informacionLaboralModel,
// 'informacionEstudioModel' => $informacionEstudioModel,
// 'informacionOficiosModel' => $informacionOficiosModel,
// ]);
}
}
`
Is there any way to make it easy? I can use the font family in the view and it works, but if I render normally, that is, using render() and not renderpartial()
`
primerNombre ?>
`
victor burbano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.