Maatwebsite Excel exporting large table in PDF using mpdf

Published 4 months ago by nizam0786

Hi guys,

I have a large customers table which can be filtered and exported as a csv, excel or pdf file.

I am using maatwebsite\excel also know as laravel excel http://www.maatwebsite.nl/laravel-excel/docs

I have it working however, when trying to download the full table only csv and excel sheet works pdf just returns a black page saying 'This site can’t be reached' but when the table is filtered and there are not many rows of data it seems to work fine.

Any idea?

Thanks in advacne.

Best Answer (As Selected By nizam0786)
nizam0786

It was my memory limit in php.ini file I got the answer from the following url:

https://stackoverflow.com/questions/34864524/allowed-memory-size-of-536870912-bytes-exhausted-in-laravel

LaraStorm

did you try setting max_execution_time

ini_set('max_execution_time', 300);

nizam0786

@LaraStorm yes I already tried that but it doesn't seem to be that. Thanks for your reply.

nizam0786

Below is the full text which is returned on white page after clicking the export button.

This site can’t be reached The web page at http://project/downloadCustomersTable/pdf might be temporarily down or it may have moved permanently to a new web address. ERR_INVALID_RESPONSE

nizam0786

in the log file the following message has been returned.

Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 134217728 bytes exhausted (tried to allocate 23338072 bytes) in C:\wamp64\www\gtc\vendor\mpdf\mpdf\mpdf.php:29373

LaraStorm

i use this function its works for me

public function getCheckedData(Request $request){
            ini_set('max_execution_time', 300);
            $msg['success'] = 'false';
            $data = $request->ck;
            $orders = orders::whereIn('waybill_id', $data)->get();
            $msg['orders'] = $orders;
            $msg['success'] = 'true';
            $pdf = PDF::loadView('admin.cod.print-view', compact(['orders']))->setPaper('a5', 'portrait');
            $rand = 'cf409ab0c5916ea';
            $msg['rand'] = $rand;
            $pdf->save('/var/www/html/impex/download/'.'imp-' . $rand . '.pdf');
            return response()->json($msg);
    }

``
nizam0786

@LaraStorm my function is alot different, thanks for your help I will still look into it I tried changing a few things but still does not work.

it keeps returning in the error log:

Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 134217728 bytes exhausted (tried to allocate 23338072 bytes) in C:\wamp64\www\gtc\vendor\mpdf\mpdf\mpdf.php:29373

nizam0786

It was my memory limit in php.ini file I got the answer from the following url:

https://stackoverflow.com/questions/34864524/allowed-memory-size-of-536870912-bytes-exhausted-in-laravel

Please sign in or create an account to participate in this conversation.