Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

strtoupper() expects parameter 1 to be string, array given

I installed dompdf and I try output pdf but I see this error.

strtoupper() expects parameter 1 to be string, array given

Controller

public function index()
{
    $articles = Article::all();
	$pdf = PDF::loadView('articles', compact('articles'),[],[
		'mode' => 'utf-8', 'format' => [233,500]
	])->save('public/file.pdf');
	return $pdf->stream('articles.pdf');
}
0 likes
4 replies
shahr's avatar
Level 10

I get this error/

strtoupper() expects parameter 1 to be string, array given

public function index()
{
	$articles = Article::all();
	$pdf = PDF::loadView('articles', compact('articles'),
		[], ['mode' => 'utf-8']
	);
	return $pdf->stream('articles.pdf');
}
MichalOravec's avatar
Level 75

@oxbir How I said 4th parameter should be a string, you put there an array ['mode' => 'utf-8']

So

$pdf = PDF::loadView('articles', compact('articles'), [], 'utf-8');
1 like

Please or to participate in this conversation.