I have set up Dom pdf in my Laravel project, but when I generate the pdf, the controller only return a 'weird string of code' instead of the pdf.
My code in te controller:
public function pdfConditions(Request $request)
{
$request->validate([
'html' => 'required'
]);
$html = $request->html;
$data = compact('html');
$pdf = Pdf::loadView('pdf.conditions', $data);
$pdf->setPaper('A4', 'portrait');
$pdf->setWarnings(false);
return $pdf->download();
}
My code in my views blade file:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
{{ $html }}
</body>
The response I receive:
So what can be the reason the pdf is not generated properly?