Search code examples
phpmysqllaravelpdfpdf-generation

Mpdf is not working after uploading to the host and showing pdf as text if i show it in the browser


I am using Mpdf in Laravel and it works well in localhost but after uploading to the host I find the pdf as being shown in the picture when I show it in the browser but if I enable downloading it instead of showing in the browser it showing the text without styling

the error that I got

and here is my controller code

$mpdf = new mPDF();
$mpdf->WriteHTML($html);
$mpdf->output();

I also tried

$pdf = PDF::loadView('test');
return $pdf->stream('document.pdf');

Solution

  • I solved the problem that I have found that after uploading to the server I put the public folder outside the Laravel project which caused the error so I put it again inside the Laravel project and the problem is solved now. thank you