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:
@@ -437,11 +437,16 @@ class CalendarBoard extends Page
|
||||
->orderBy('time_start')
|
||||
->get();
|
||||
|
||||
$pdf = \Barryvdh\DomPDF\Facade\Pdf::loadView('pdf.appointments', [
|
||||
$appointmentsHtml = view('pdf.appointments', [
|
||||
'appointments' => $appointments->groupBy(fn ($a) => $a->date->toDateString()),
|
||||
'periodLabel' => Carbon::parse($firstDate)->format('d.m.Y') . ' — ' . Carbon::parse($lastDate)->format('d.m.Y'),
|
||||
'generatedAt' => now()->format('d.m.Y H:i'),
|
||||
])->setPaper('a4', 'portrait');
|
||||
])->render();
|
||||
$appointmentsHtml = strtr($appointmentsHtml, [
|
||||
"\u{0219}" => "\u{015F}", "\u{0218}" => "\u{015E}",
|
||||
"\u{021B}" => "\u{0163}", "\u{021A}" => "\u{0162}",
|
||||
]);
|
||||
$pdf = \Barryvdh\DomPDF\Facade\Pdf::loadHTML($appointmentsHtml)->setPaper('a4', 'portrait');
|
||||
|
||||
$filename = 'programari_' . $firstDate . '_' . $lastDate . '.pdf';
|
||||
$disposition = request()->boolean('download') ? 'attachment' : 'inline';
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user