Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

868
Views
Laravel: DOMPDF error when trying to get PDF

I've been trying to get the PDF of a view using DOMPDF with a table full of ingredients populated from a database table.

I created a function in my Controller:

public function createPDF() {
      // retreive all records from db
      $data = Ingredients::all();

      // share data to view
      view()->share('ingredients', $data);
      $pdf = PDF::loadView('printableingredientslist', $data);

      // download PDF file with download method
      return $pdf->download('printableingredientslist.pdf');
    }

And the route in web.php is defined as:

Route::get('/printpreviewingredients/pdf', [MealPlanDisplayController::class, 'createPDF']);

However, I keep getting this error:

fopen(D:\mealplan\storage\fonts//nunito_normal_46b9b3b48cc3ddbae60da82f1c1c5d29.ufm): failed to open stream: No such file or directory

It must be something to do with the 'printableingredientslist' as when I replaced it with a plain view page with simple text that worked. I am struggling to see how there's a path issue however, as printableingredientslist.blade.php is simply under the views folder. What can the issue be? I am using tailwind.css, could that be a problem?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

setOptions method to use default font.For example like below

public function pdf() 
{ 
    $pdf = \PDF::loadView('contact')->setOptions(['defaultFont' => 'sans-serif']); 
        
    return $pdf->download('invoice.pdf'); 
}

or

Create the directory fonts in storage directory

Ref: https://github.com/barryvdh/laravel-dompdf/issues/724

Ref:https://github.com/barryvdh/laravel-dompdf/issues/176

Ref:https://github.com/barryvdh/laravel-dompdf/issues/269

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!