Laravel: DOMPDF error when trying to get PDF

Viewed 867

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?

1 Answers
Related