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

moses's avatar
Level 2

How to add title tab browser when open pdf (laravel dompdf)?

I get from here : https://github.com/barryvdh/laravel-dompdf

My controller is like this :

public function listdata()
{
    $pdf=PDF::loadView('print_tests.test_pdf');
    $pdf->setPaper('L', 'landscape');
    return $pdf->stream('test_pdf.pdf');
}

My view is like this :

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>test title</title>
        <body>
...

I try to change the title to be <title>test title</title>, but when pdf opened, it's not working. I try find reference, but i can't fint it

Is there any people who can help me?

0 likes
1 reply
yuyenkan's avatar

Your problem may be the name of view file? it should be print_tests.blade.php and loadView('print_tests'), or try to get latest version of the plugin, on myside it is working with

<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>Test</title>
</head>
<body>
	<div class="container">
		Test Content
	</div>
</body>
</html>

Please or to participate in this conversation.