I'm using mPDF in codeigniter project. It's working well for English and Russian language but in Yiddish language it's showing only dots (.) and commas (,) like below:
While the content I'm writing in it is:
Here is my code:
$mpdf = new \Mpdf\Mpdf();
$mpdf->SetFont('avenirnext');
$mpdf->SetTitle($title);
$mpdf->SetAuthor('Blavatnik');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($stylesheet2, 1);
$mpdf->WriteHTML($stylesheet3, 1);
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->SetHtmlHeader($header, 'OE');
$mpdf->SetHTMLFooter($footer, 'OE');
$mpdf->WriteHTML($html);
if ($html2 != '' && $html3 != '') {
$mpdf->SetHtmlHeader($secondHeader, 'OE');
$mpdf->WriteHTML($html2);
$mpdf->SetHtmlHeader($header, 'OE');
$mpdf->WriteHTML($html3);
}
if ($transcriptHtml2 != '' && $transcriptHtml3 != '') {
$mpdf->WriteHTML($transcriptHtml2);
$mpdf->WriteHTML($transcriptHtml3);
}
$mpdf->Output($title . '.pdf', 'I');
I've also tried using below solution:
$mpdf = new mPDF('utf-8');
$mpdf->SetDirectionality('rtl');
What else I can change it it to make it work for all language or mainly this Yiddish language. Thanks!
You have to use a font supporting hebrew characters. Furthermore, avenirnext
is not in a standard distribution and you have not configured an additional font.
Remove the SetFont
call and use
$mpdf->autoLangToFont = true;
along with lang="yi"
or lang="he"
in a div
or a span
around your hebrew/yiddish text.
You can also find example code in a autofont mPDF example file.