laravel-dompdf icon indicating copy to clipboard operation
laravel-dompdf copied to clipboard

Is it possible pass data to loadHTML method ?

Open Khaledsb opened this issue 2 years ago • 7 comments

Hello, I would like to ask everyone. I want to pass data from my code to html content with loadHTML method without use loadView .

example : show list of (Model result inside pdf).

Thank You

Khaledsb avatar Dec 27 '22 10:12 Khaledsb

No

parallels999 avatar Dec 27 '22 13:12 parallels999

@parallels999 can you give me un example please , i tried this but isn't working
$pdf->loadHTML($template->content, ['test' => 'test']);

Khaledsb avatar Dec 27 '22 13:12 Khaledsb

https://github.com/barryvdh/laravel-dompdf/blob/7516caab940796d31267da9b30b548a56bef50cb/src/PDF.php#L81-L92

parallels999 avatar Dec 27 '22 14:12 parallels999

the second paramter is for encoding not for data @parallels999 can you give me a real example ?

Khaledsb avatar Dec 27 '22 14:12 Khaledsb

While you cannot pass data directly to loadHTML(), you can build html from a blade view manually and then pass that in

// create a view, pass data, and get the html content
$html = response()->view($view, ['test' => 'test'])->getContent();


// pass html to pdf
PDF::loadHTML($html);

jameswagoner avatar Jan 06 '23 16:01 jameswagoner

@jameswagoner yes , that what i did as solution, thank you :)

Khaledsb avatar Jan 08 '23 08:01 Khaledsb

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 18 '23 08:06 stale[bot]