Pankaj
Pankaj

Reputation: 10115

Issue while trying to convert Html into PDF in Laravel

I am trying to create PDF from a Blade. My View has example same static Html as showing in this plunker link

My code is simple...using barryvdh/laravel-dompdf package...I am writing below code in controller action method

$pdf = \PDF::loadView('ViewPage', ["Data" => 123]);
return $pdf->download('sample.pdf');

Now, the problem is when i view it in html page...it works perfectly and we may check the correct expected output here: https://plnkr.co/edit/an7JsFSkNt52oKi0Oupg?p=preview ...but when I run above code to put the exact same html into PDF...it shows something like this

Am I missing anything?

enter image description here

Upvotes: 0

Views: 1965

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111889

Styling PDF is often tricky. You should inline CSS code into your HTML/Blade view and it's quite possible you will need to modify HTML code to make it work in PDF. DomPDF doesn't support everything that is supported when displaying HTML page.

Upvotes: 1

Related Questions