Fix Romanian diacritics (ș ț) and Cyrillic in DomPDF-generated PDFs

DejaVu Sans lacks glyphs for U+0219 (ș) and U+021B (ț). Fix: render
view to HTML first, replace with cedilla variants (U+015F/U+0163) that
DejaVu Sans supports, then load HTML. Set default_font to DejaVu Sans.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-06 12:03:24 +00:00
parent 8a359f4440
commit 63ef482514
3 changed files with 319 additions and 4 deletions
+11 -2
View File
@@ -33,7 +33,7 @@ class WorkOrderPdfService
}
}
return Pdf::loadView('pdf.work-order', [
$html = view('pdf.work-order', [
'wo' => $wo,
'company' => $company,
'themeColor' => $themeColor,
@@ -43,7 +43,16 @@ class WorkOrderPdfService
'paid' => $paid,
'balance' => $balance,
'logoData' => $logoData,
])->setPaper('A4');
])->render();
// DejaVu Sans lacks U+0219 (ș) and U+021B (ț) — normalize to cedilla
// variants (U+015F ş, U+0163 ţ) which are visually identical and supported.
$html = strtr($html, [
"\u{0219}" => "\u{015F}", "\u{0218}" => "\u{015E}",
"\u{021B}" => "\u{0163}", "\u{021A}" => "\u{0162}",
]);
return Pdf::loadHTML($html)->setPaper('A4');
}
public function filename(WorkOrder $wo): string