You must use this codes in your header
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body { font-family: DejaVu Sans, sans-serif; }
</style>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
DOMPDF is giving ??? error for arabic language but when i solved that is not showing correct words.
You must use this codes in your header
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body { font-family: DejaVu Sans, sans-serif; }
</style>
@Emtized not helpfull
Hi Try this
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
//$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8',array(6, 3, 9, 3));
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', '');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetMargins(5,5,5);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setPrintHeader(false);
// set Display
$pdf->SetDisplayMode('fullpage');
// add a page
$pdf->AddPage();
// set some text to print
$html=<<<EOD
$newhtml
EOD;
// print a block of text using Write()
//print_r($html);exit;
//$pdf->Write(0, $html, '', 0, 'C', true, 0, false, false, 0);
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
// ---------------------------------------------------------
//ob_end_clean();
//Close and output PDF document
$magazineDir = getcwd().'/pdf/'.$id;
//chmod($magazineDir.'/Magazine_'.$curr_language.'.pdf', 0755);
if(!is_dir($magazineDir))
{
mkdir($magazineDir);
}
//Store pdf
$pdf->Output($magazineDir.'/Magazine'.pdf',"F");
@HSNCH41 Pate your Controller code here in discussion. so i can help you further.
Tip: UTF-8 support
In your templates(invoice.blade.php), set the UTF-8 Metatag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');
Hope this will help.
for further assistance check this : https://github.com/barryvdh/laravel-dompdf
@ekhlas if ($fee) { $pdf = PDF::loadView('admin.templates.fee-new', compact('fee','days')); return $pdf->stream('fee-receipt-' . $fee->student->last_name . '.pdf'); }
hi @hsnch41
in <head> section add this<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> in admin.templates.fee-new.blade.php
@hsnch41 You also need to make sure that the used font supports Arabic characters. Make sure to define a font you know will work in the pdf template CSS or change "default_font" in config/dompdf.php
@Nash not helpful.can you please explain.
@hsnch41 It could be that dompdf uses a default font that does not support Arabic characters. You can set the font with CSS in your pdf template (like you would do for any other html page) or you could change the default font in the dompdf config. See "configuration" in docs:
@Nash i have changed my font to body { font-family: DejaVu Sans, sans-serif; } but then can't fixed arabic font direction.
@hsnch41 It looks like dompdf has some issues with Arabic and RTL:
It might be easier to just switch to another pdf library, for example mPDF. It appears to have better support for Arabic:
@nash tell me best package for pdf reports that support all languages display.
you can use this package which supports rtl languages such as persian and arabic
Please or to participate in this conversation.