I use laravel dompdf to create PDF files. What I'm trying to do is create pdf file, upload it to storage and then download it. there's specific endpoint, when user call it all these actions happen.
// fetch data for pdf
$pdfData = $this->getData();
// creates pdf from html
$pdf = PDF::loadView('pdf.example', [
'items' => $pdfData
])->setPaper('a4', 'landscape');
// upload file to storage
Storage::put("/my-path", $pdf->output());
// download file
return $pdf->download("file.pdf");
In html(from which pdf's been created) I have custom fonts(load them with @font-face
). the issue is that after calling output method $pdf->output()
the characters in pdf are invalid
BUT, if I don't call $pdf->output()
characters are shown properly(with my custom fonts). so the issue happens only when I use custom fonts and then call $pdf->output()
. any idea how to fix it?
I already saw this solution but it doesn't help, also there's no load_font.php
in this package