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

Duckz_1209's avatar

DOMPDF Report

is it possible to generate pdf using dompdf without internet connection?

0 likes
13 replies
Sinnbeck's avatar

I see no reason why not. Just run the website locally on the same computer

Duckz_1209's avatar

can it be load faster? or it just cant handle large table?

Duckz_1209's avatar

i generate 1500 rows and dompdf cant handle it. it always says maximum execution time error

Sinnbeck's avatar

If you local computer is very fast it might, but it depends on the computer specs.

Are you having problems? What are you trying to do? Do you get an error?

Duckz_1209's avatar

i generate pdf using dompdf. it runs smooth if its just a few rows until a couple hundreds but when it reach thousand rows, it just cant generate until i receive maximum execution time error

Duckz_1209's avatar

there no other way to generate large rows faster?

Sinnbeck's avatar

Perhaps if you showed some code I could give some suggestions

Duckz_1209's avatar

public function export_pdf ($startdate, $enddate)

 {

 $payments = Payment::whereDate('created_at','>=',  $startdate)->whereDate('created_at','<=',  $enddate)->where('loan_id', '!=', 0)->get();

    $loan_amount = Payment::whereDate('created_at','>=',  $startdate)->whereDate('created_at','<=',  $enddate)->where('loan_id', '!=', 0)->sum('loan_amount');
    
$loan_interest = Payment::whereDate('created_at','>=',  $startdate)->whereDate('created_at','<=',  $enddate)->where('loan_id', '!=', 0)->sum('loan_interest');
    
$loan_cbu = Payment::whereDate('created_at','>=',  $startdate)->whereDate('created_at','<=',  $enddate)->where('loan_id', '!=', 0)->sum('loan_cbu');
    
$loan_penalty = Payment::whereDate('created_at','>=',  $startdate)->whereDate('created_at','<=',  $enddate)->where('loan_id', '!=', 0)->sum('loan_penalty');
    
 $total = $loan_amount+$loan_interest+$loan_cbu+$loan_penalty;
    
 $date = Carbon::now()->format('d/m/Y');

    $pdf=PDF::loadView('crb.pdf',compact('clients','payments', 'date', 'loan_amount', 'loan_interest', 'loan_cbu', 'loan_penalty', 'total'));
    $pdf->setPaper('legal', 'landscape');

    return $pdf->stream('crb.pdf');

}
Duckz_1209's avatar

the code works fine if the rows are just a couple hundreds but if it reach more than thousands, its so slow to generate

Sinnbeck's avatar

Your code is fine. My only suggestion is to look into optimizing your database

Duckz_1209's avatar

i need to generate thousand of rows but dompdf can't

erikverbeek's avatar

As an alternative you could look at Browsershot, and it's Laravel helper.

Browsershot runs a Chromium headless browser on your server to generate the HTML that gets turned into the PDF. This makes it a more powerful alternative to DOMPDF, which tries to compile the HTML itself.

Please or to participate in this conversation.