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

rvsky's avatar
Level 1

Dompdf doesn't render PDF, but only loading page

Hallo. I want to export my page to pdf but I can not do it. My page is only loading and I do not know what do to next... Can u help me?

Here's some code:

Controller:

public function htmltopdfview($id) { $client = Client::findOrFail($id); $pdf = PDF::loadView('client/print', compact('client')); return $pdf->stream(); }

web.php

Route::get('printt/{id}',array('as'=>'printt','uses'=>'ClientController@htmltopdfview'));

and view:

                {!! Form::open(['action' => ['ClientController@doEdit', $client->id]]) !!}
                {!! Form::label('name', 'Imie i nazwisko:'); !!}
                {!! Form::text('name', null, ['class' => 'form-control']) !!}
        {!! Form::submit('Edit!', ['class' => 'btn btn-success']) !!}
                {!! Form::close() !!}
0 likes
1 reply
AddWebContribution's avatar

Try below code:

public function htmltopdfview($id) { 
    $client = Client::findOrFail($id); 
    $pdf = PDF::loadView('client/print', compact('client'))->save('client.pdf'); 
    return $pdf->stream('client.pdf');
}

Please or to participate in this conversation.