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

Malformed UTF-8 characters, possibly incorrectly encoded

Open zakariayad opened this issue 2 years ago • 5 comments

why keep getting this error message (Malformed UTF-8 characters, possibly incorrectly encoded) even that i've set my blade meta charset ( ), and i can see in the request header that the encoding method is UTF_8, i did install the package correctly, why is that hapening and how can i solve that.

zakariayad avatar Oct 31 '23 13:10 zakariayad

try this return response()->streamDownload(function () use ($pdf) { echo $pdf->stream(); }, 'name.pdf');

TigselemaAlex avatar Nov 01 '23 15:11 TigselemaAlex

try this return response()->streamDownload(function () use ($pdf) { echo $pdf->stream(); }, 'name.pdf');

it works for me thank you, but i wish if you could tell me what was the problem

zakariayad avatar Nov 01 '23 16:11 zakariayad

Any explanation on why the problem occurred? @TigselemaAlex

risangbaskoro avatar Nov 21 '23 07:11 risangbaskoro

bytes vs raw text

parallels999 avatar Nov 21 '23 13:11 parallels999

Any explanation on why the problem occurred? @TigselemaAlex

I'm not a Laravel expert, but I think it's because it's trying to show in a view the pdf data stream and that's why this error occurs. The only solution I found was that.

TigselemaAlex avatar Nov 23 '23 14:11 TigselemaAlex

try this return response()->streamDownload(function () use ($pdf) { echo $pdf->stream(); }, 'name.pdf');

Its worked for me.But not showing svg files.

dulshan-devops avatar Apr 10 '24 13:04 dulshan-devops

It worked for me too. But, it would be nice for the error to be handled directly a lib.

themegazord avatar Apr 17 '24 12:04 themegazord

It's April 2024 I still got tripped by this issue.

I confirm that the solution posted by @TigselemaAlex works but as @themegazord said, it would be nice to have this fixed in the lib.

"barryvdh/laravel-dompdf": "2.1.1"

PHP Version
8.2.x

Laravel Version
10.48.4

Alpine Version
3.13.8

Theme
Tailwind 3.x

rpringadi avatar Apr 24 '24 15:04 rpringadi

try this return response()->streamDownload(function () use ($pdf) { echo $pdf->stream(); }, 'name.pdf');

Bro thanks a lot you saved my life <3

mr-abdellah avatar Aug 06 '24 11:08 mr-abdellah

facing the same problem, @TigselemaAlex solution work ! genius.

jazzy1986 avatar Aug 21 '24 07:08 jazzy1986