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

MWDeveloper's avatar

DomPDF download()

Hi everybody I save a pdf to public path and when i want to download it or stream it, It generates other pdfs and fails to download the one I call Any idea ?

0 likes
2 replies
eduphp8's avatar

Hello, maybe you have a route pointing to a similar path. It is the only cause that comes to mind right now. Make sure the folder you are saving your file dont match some route like Route::get('pdf',...);

MWDeveloper's avatar

Thanks @swalker2 for the reply. I revised the route file but there is no problem from this kind !! .here is my code to make it clear to understand what's happening

$pdf = PDF::loadView('pdfs.result', [ 'user'=>$user ])->save(public_path('/pdfs/'.'_'.$user->id.'.pdf' )); return $pdf->stream();//also the download method do the same thing.

return a downloadable link looks like this ''http://localhost:8000/users" and when i download it it generate the same pdf with incremented ids in their file names. something like 144.pdf ,145.pdf and 146.pdf

Please or to participate in this conversation.