From 00239bb6c85e36cf724c2c9dfce7e3deb7c558a2 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 22 Apr 2026 13:22:20 +0100 Subject: [PATCH] Exports: Improved dompdf font loading permission errors --- app/Exports/PdfGenerator.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Exports/PdfGenerator.php b/app/Exports/PdfGenerator.php index 10f0624cf..5506fe740 100644 --- a/app/Exports/PdfGenerator.php +++ b/app/Exports/PdfGenerator.php @@ -65,7 +65,12 @@ class PdfGenerator $fontMetrics = $domPdf->getFontMetrics(); $userFontfamilies = $this->getUserDomPdfFontFamilies(); foreach ($userFontfamilies as $fontFamily => $fonts) { - $fontMetrics->setFontFamily($fontFamily, $fonts); + try { + $fontMetrics->setFontFamily($fontFamily, $fonts); + } catch (\Exception $exception) { + $expectedPath = storage_path('fonts/dompdf'); + throw new PdfExportException("Failed to create required font data in {$expectedPath}, Ensure all content in this location is writable by the web server"); + } } $domPdf->loadHTML($this->convertEntities($html)); @@ -92,7 +97,11 @@ class PdfGenerator if (!file_exists($expectedUfm)) { $font = Font::load($fontFile); $font->parse(); - $font->saveAdobeFontMetrics($expectedUfm); + try { + $font->saveAdobeFontMetrics($expectedUfm); + } catch (\Exception $exception) { + throw new PdfExportException("Failed to create required font data at $expectedUfm, Ensure this location is writable by the web server"); + } } $nameParts = explode('-', $fontFileName);