Answer the question
In order to leave comments, you need to log in
How to force mpdf in Yii2 to display Russian letters?
I use this extension: www.yiiframework.com/extension/yii2-mpdf Installed
, configured and everything seems to be fine, but stubbornly refuses to display Russian letters.
The code:
public function actionTest()
{
Yii::$app->response->format = Response::FORMAT_RAW;
$headers = Yii::$app->response->headers;
$headers->add('Content-Type', 'application/pdf');
$content = $this->renderPartial('pdf');
$pdf = new Pdf([
'mode' => Pdf::MODE_CORE, // leaner size using standard fonts
// A4 paper format
'format' => Pdf::FORMAT_A4,
// portrait orientation
'orientation' => Pdf::ORIENT_PORTRAIT,
// stream to browser inline
'destination' => Pdf::DEST_BROWSER,
'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
'content' => $content,
'options' => [
'title' => 'Распечатка события - Service Desk',
'subject' => 'Service Desk'
],
'defaultFont' => 'Arial',
'methods' => [
'SetHeader' => ['Service Desk||Generated On: ' . date("Y-m-d H:i:s")],
'SetFooter' => ['{PAGENO}']
]
]);
return $pdf->render();
}
<p>Документ pdf</p>
Answer the question
In order to leave comments, you need to log in
You need
to replace the line with'mode' => Pdf::MODE_UTF8,
Good morning.
So maybe the problem is not in mpdf?
Check if you have the required encoding everywhere (file, server, etc.)
$pdf->charset_in = 'utf-8'; ?
and in constructor
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8', // вот енто
'format' => [190, 236],
'orientation' => 'L'
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question