Hashibul Hasan
Hashibul Hasan

Reputation: 51

laravel-dompdf return error,code not work

I have this code to try to generate a report as pdf:

$details=array(
    'id'=>$find->id,
    'full_letter_title'=>$find->full_letter_title,
    'smarok_no'=>$find->smarok_no
);
$data['details']=$details;


$pdf = PDF::loadView('letter.view', $data);
return $pdf->stream();

But it return error

ErrorException in Adobe_Font_Metrics.php line 42: fopen(C:\xampp\htdocs\ams\storage\fonts/ba50cf37c0b6d75f8275d2b44106f606.ufm): failed to open stream: No such file or directory

I cant understand whats wrong here.

Upvotes: 1

Views: 3504

Answers (3)

Haroon Mahmood
Haroon Mahmood

Reputation: 381

Try this:

$pdf = PDF::loadView('letter.view', $data)->setOptions(['defaultFont' => 'sans-serif']);

It worked for me, i didn't create any font folder/file

Upvotes: 0

Ayman Elshehawy
Ayman Elshehawy

Reputation: 2954

STEPS

  1. crate "fonts" Folder inside storage
  2. create file "5ab413ede0c0d14abbb48febee3bfdfb.ufm" or other "File Name" Which show in error inside "fonts" Folder
  3. Giving Permission "fonts" Folder

NOW IT'S RUN

[reference] (https://github.com/barryvdh/laravel-dompdf/issues/269)

Upvotes: 1

Narayan Kumar
Narayan Kumar

Reputation: 16

This will be solved by creating Font Directory inside the Storage folder. This is used to store the temporary files . But anyhow Dompdf is not a effective library for PDF . I already used this and gotta more css issues about alignments . I would suggest you to use the Phanthomjs PDF . https://github.com/danielboendergaard/phantom-pdf It's much better than DomPDF .

Upvotes: 0

Related Questions