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

4jZW7jVSdS4U6PC's avatar

View PDF in Laravel

What's the best way to show a PDF in-browser with Laravel?

I want a sort of link that opens a new page and you can view the PDF with Chrome, Firefox, Opera etc

0 likes
8 replies
Prullenbak's avatar
Level 26

If I understand you correctly, you just need to make a link to the pdf so

<a href="file.pdf">Open the pdf!</a>

or if you use blade and the pdf file is somewhere in your public directory:

<a href="{{ asset('files/file.pdf') }}">Open the pdf!</a>
Cocoon's avatar

There is also a link_to_asset function that you can use in blade.

{{ link_to_asset('files/file.pdf', 'Open the pdf!') }}
1 like
Rambo's avatar

for some reason, what laravel package do you recommend to view pdf file without going out of the application?

muazamhussain's avatar

Today I'm using response->file() method to show a pdf file in the browser but instead of showing that file in the browser, it starts downloading. Is there any other way to do that same work.

younus's avatar

Is there a way where we can force to download only a smaller portion of the file?

Please or to participate in this conversation.