diff --git a/config/dompdf.php b/config/dompdf.php index 8ad2022..122546a 100644 --- a/config/dompdf.php +++ b/config/dompdf.php @@ -53,7 +53,7 @@ * This directory contains the cached font metrics for the fonts used by DOMPDF. * This directory can be the same as DOMPDF_FONT_DIR * - * Note: This directory must exist and be writable by the webserver process. + * Note: This directory must be writable by the webserver process. */ "font_cache" => storage_path('fonts'), diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 6392091..2d62f21 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -4,6 +4,7 @@ use Dompdf\Dompdf; use Exception; +use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Illuminate\Support\ServiceProvider as IlluminateServiceProvider; @@ -64,6 +65,8 @@ public function register(): void $this->app->bind('dompdf.wrapper', function ($app) { return new PDF($app['dompdf'], $app['config'], $app['files'], $app['view']); }); + + File::ensureDirectoryExists($app['config']->get('dompdf.options.font_cache')); } /**