Closed sagadsalem closed 3 years ago
I have the same problem, after generate PDF showed ????? character in page.
html:
<!doctype html>
<html lang="fa">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
</head>
<body>
<h1>به نام خدای بخشنده و مهربان</h1>
</body>
</html>
implementation:
install this https://github.com/mRamadan0101/dompdf
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.
Facing the same issue.
Creating the PDF, all the other fonts like English, Hindi etc looks fine but the Arabic font is reversed when creating the pdf.
الإغتيالات والسموم الكيميائية is change to ةيئايميكلا مومسلاو تالايتغإلا
I faced the same issue, no solution worked for me yet.
i face issue when i use arabic font is reversed any solution for that thanks ...???
finally i got the solution This setup is designed to help you integrate custom fonts with mPDF in a Laravel project, specifically using fonts for Arabic text rendering.
composer require mpdf/mpdf
/public/fonts/Amiri-Regular.ttf /public/fonts/Amiri-Bold.ttf
`@font-face { font-family: "Amiri"; src: url('{{ asset('/fonts/Amiri-Regular.ttf') }}') format('truetype'); font-weight: normal; font-style: normal; }
@font-face { font-family: "Amiri"; src: url('{{ asset('/fonts/Amiri-Bold.ttf') }}') format('truetype'); font-weight: bold; font-style: normal; }
body { font-family: 'Amiri'; margin: 0; padding: 0; background-color: #f4f7f6; color: #333; direction: rtl; / RTL direction for Arabic / } `
`public function generatePDFAR(Quote $quote) { $companyProfile = CompanyProfile::first(); // Fetching the first company profile entry
// Setup custom font directory and font data configuration $fontDirs = [public_path('fonts')]; $fontData = [ 'amiri' => [ 'R' => 'Amiri-Regular.ttf', 'B' => 'Amiri-Bold.ttf' ] ]; $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $defaultFontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); $defaultFontData = $defaultFontConfig['fontdata']; $mpdf = new \Mpdf\Mpdf([ 'mode' => 'utf-8', 'format' => 'A4', 'orientation' => 'P', 'autoScriptToLang' => true, 'autoLangToFont' => true, 'fontDir' => array_merge($defaultFontDirs, $fontDirs), // Merge default font directory with your custom directory 'fontdata' => $fontData + $defaultFontData, // Merge default font data with your custom font data 'default_font' => 'amiri' // Set default font to Amiri ]); $view = view('quotes.quotes-ar', compact('quote', 'companyProfile'))->render(); // Render view to HTML string $mpdf->WriteHTML($view); return $mpdf->Output('quotes_ar.pdf', 'I'); // Output PDF to browser
} `
Feel Free to Ask Any Questions good luck :)
hi Arabic characters are in reversed its show like:
should show like:
i have default configration but in my template i use: