0

I am inside a laravel 5.7 application, using the package barryvdh / laravel-snappy and trying everything (this code is the last attempt), to generate a dynamically PDF that has at least 2,000 pages.

This code is about my last attempt inside the view.

 \DB::table(\DB::raw('`n_f_blocks`'))
     ->join('n_f_files', 'n_f_files.id', '=', 'n_f_blocks.n_f_file_id')
     ->where('n_f_files.group_id', '=', $file->id)
     ->where('tipo', 'saida')->orderBy('n_f_blocks.id', 'asc')->chunk(1000, function($data) {
        foreach($data as $nf) :

        @endphp
            <tr>
                <th scope="row">{{ $nf->nota }}</th>
                <td>{{ $nf->chave }}</td>
                <td>{{ date("d/m/Y", strtotime($nf->data)) }}</td>
                <td>{{ $nf->mod }}</td>
                <td>{{ $nf->ser }}</td>

                <td>{{ $nf->bc_pis_original }}</td>
                <td>{{ $nf->bc_cofins_original }}</td>
                <td>{{ $nf->pis_original }}</td>
                <td>{{ $nf->cofins_original }}</td>
                <td>{{ $nf->icms_original }}</td>

                <td>{{ $nf->bc_pis_processado }}</td>
                <td>{{ $nf->bc_cofins_processado }}</td>
                <td>{{ $nf->pis_processado }}</td>
                <td>{{ $nf->cofins_processado }}</td>
                <td>{{ $nf->icms_processado }}</td>
            </tr>
        @php
        endforeach;

        });
        @endphp

It is possible?

I already received several errors, timeout, max memory size ..

I really do not know how to solve.

paccamicio
  • 76
  • 1
  • 5
  • 4
    You will probably need to generate smaller PDFs (of say, a couple dozen pages at once) and then [combine them](https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf). – ceejayoz Dec 14 '18 at 22:19
  • generating 2000 pages can take 2gb or more easily (if they contain images etc). So the better approach is to generate single paged pdf files and then just combine them using a tool that takes files as input and merges pdf files into a single output one – Eugene Dec 15 '18 at 00:56

0 Answers0