Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ekn's avatar
Level 1

laravel-dompdf: Permission denied

When generating my PDF with custom fonts and trying to stream like this:

$pdf = PDF::loadView( '/pdfs/invoice',$data); 
return $pdf->stream();

I am getting this Error (on production environment deployed with Deployer):

fopen(/var/www/html/laravel-app/releases/1/vendor/dompdf/dompdf/lib/fonts/roboto-regular-normal_9bbdfe1036add21d2565492aa3ed0be4.ufm): failed to open stream: Permission denied

I load the font within my invoice.blade.php like this:

@font-face { 
    font-family: 'Roboto-Regular'; 
    src: url({{storage_path('fonts/Roboto-Regular.ttf')}}) format("truetype"); 
}

And I have saved my Font files within storage/fonts. Also I have added 'storage/fonts' to writable_dirs within deploy.php.

I am stuck here because I cannot set permission for every release within vendor files AND also I do not understand why the Font Caching is processed there. It should be done within my storage/fonts directory, since in config/dompdf.php there is this:

"font_dir" => storage_path('fonts/'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782) 
"font_cache" => storage_path('fonts/cache/'),

I have searched a lot and tried many things but I cannot resolve this. If anyone experience could give me a help here I would be very thankful.

FYI: On local everything works fine. Also if I generate the pdf and use $pdf->output() to attach it to an email everything works fine.

0 likes
3 replies
LCFans's avatar

I am facing the same issue.

1 like
Snapey's avatar

put the fonts in a folder then set the config;

fontDir: "{app_directory}/storage/fonts/" (available in config/dompdf.php)

Please or to participate in this conversation.