Export blade using laravel-dompdf version 2.0

198 Views Asked by At

i try to export a blade view using the package barryvdh/laravel-dompdf but i get an error

Undefined array key "" in /var/www/html/vendor/dompdf/dompdf/lib/Cpdf.php line 4752 /var/www/html/vendor/dompdf/dompdf/src/Adapter/CPDF.php", line: 806, function: "getFontHeight", ..... etc..... /var/www/html/app/Http/Controllers/PdfController.php", line: 193

Here is my PdfController line 193

192: $pdf = Pdf::loadView("template.pdf"); 
193: Storage::disk('local')->put('public/pdf/test.pdf',$pdf->output());

here is my template/pdf.blade.php

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>PDF </title>
</head>

<body>TEST</body>
</html>

but when I try with barryvdh/laravel-dompdf version 1.0, iIt outputs correctly.What's the problem?

1

There are 1 best solutions below

3
Shabeeb Ali On

Try this one

Pdf::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);
$pdf = Pdf::loadView("template.pdf");
Storage::disk('local')->put('public/pdf/test.pdf',$pdf->output());