Level 42
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');
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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() !!}
Please or to participate in this conversation.