'Dompdf is writing on top of other html elements - Laravel 6 - PHP 8
I'm writing a function to create and display a pdf file using Dompdf in a Laravel 6 project using PHP 8. I tried with many tutorials and even the official documentation from GitHub for the normal Dompdf version and it's wrapper for Laravel. Here is my pdf generator function code:
private function generate_pdf(){
$html = '
<html>
<body>
<h1>Hello Dompdf</h1>
<h2>MDF</h2>
</body>
</html>
';
$pdf = PDF::loadHTML($html);
return $pdf->stream('welcome.pdf');
}
It works fine but here is the result of the function:
As you can see the elements are overlapping itself on top of each others. I looked for answers but I can't find anything related. Does somebody knows why is this happening?
Solution 1:[1]
The problem is compatibility with PHP 8 itself. I had the same issue and downgrading to PHP 7.4 has worked on my server. Not sure where the incompatibility may be, but immediately after updating to PHP 8.0 DOMPDF stopped interpreting the HTML properly and started placing items on top of each other.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GeoSn0w |

