PDF does not generate all pages with mPDF

0

I have a query that returns me 8,093 records in both the database and a system in PHP. I'm making a report using mPDF that independently of the filter, it only generates 6 pages, which in my opinion, rule out the possibility of getting some null or unformatted data. My report has header and footer and is printing 25 lines per page.

    <?php 
    include 'MPDF57/mpdf.php'; 
 include 'conect/conecta.php';
 include 'banco-os.php';
 include 'logica-usuario.php';

 $OSid              = $_POST['OSid'];
 $dataHora          = $_POST['dataHora'];
 $NomeEquipamento   = $_POST['NomeEquipamento'];
 $NomeSetor         = $_POST['NomeSetor'];
 $motivoOs          = $_POST['motivoOs'];
 $TotalMaterial     = $_POST['TotalMaterial'];
 $NomeTipoOS        = $_POST['NomeTipoOS'];
 $status            = $_POST['status'];

 $topo = "

    <table border='1' class='table table-striped'  style='font-size: 12px;' >
        <tr>
            <td colspan='1' width='10%'><img src='imagens/logo-mini.png' class='img-responsive img-rounded'></td>
            <td colspan='7' width='90%' class='textCenter'>
                <p>            
                    Av. Lobo Júnior, 688 - Penha Circular - Rio de Janeiro - RJ<br>CEP: 21020-125
                    Telefones: 2156-0500<br > Assistência Técnica: 2156-0525 <br>
                    E-mail: <a href='mailto:[email protected]'>[email protected]</a> - Site: <a href='www.riomed.com.br'>www.riomed.com.br</a>                
                </p>
            </td>            
        </tr>        
    </table>";

 $corpo_pagina = "
<!DOCTYPE html>
<html lang='pt-br'>
<head>
    <meta charset='UTF-8'>
    <title>Relatório - RioMed</title>
    <link href='css/bootstrap.css'  rel='stylesheet'>
    <style media='print'>
        body {
            font-family: sans-serif;
            }
    a {
        color: #000066;
        text-decoration: none;
    }
    table {
        border-collapse: collapse;
    }
    thead {
        vertical-align: bottom;
        text-align: center;
        font-weight: bold;
    }

    tfoot {
        text-align: center;
        font-weight: bold;
    }
    th {
        text-align: left;
        padding-left: 0.35em;
        padding-right: 0.35em;
        padding-top: 0.35em;
        padding-bottom: 0.35em;
        vertical-align: top;
    }
    td {
        padding-left: 0.35em;
        padding-right: 0.35em;
        padding-top: 0.35em;
        padding-bottom: 0.35em;
        vertical-align: top;
    }
    .textCenter{
        text-align: center;
        }

    img {
        margin: 0.2em;
        vertical-align: middle;
    }
    table.print-friendly tr td, table.print-friendly tr th {
        page-break-inside: avoid;
    }
    </style>

</head>
<body>


    <table border='1' class='table table-striped'  style='font-size: 12px;'  >
        <thead> 
            <tr>
                <th width='6%'>COD OS</th>
                <th width='8%'>DATA</th>   
                <th>SETOR</th>  
                <th>EQUIPAMENTO</th>            

                <th width='12%'>CUSTO TOTAL</th>
                <th>TIPO OS</th>
                <th width='17%'>STATUS</th>
            </tr>
        </thead>";
            for($i = 0; $i < count($OSid); $i++){   
                $corpo_pagina .="
        <tr>
            <td>".$OSid[$i]."</td>
            <td>".$dataHora[$i]."</td>
            <td>".$NomeSetor[$i]."</td>    
            <td>".$NomeEquipamento[$i]."</td>            
            <td>".$TotalMaterial[$i]."</td>
            <td>".$NomeTipoOS[$i]."</td>
            <td>".$status[$i]."</td>
        </tr>
        ";                
        }

$corpo_pagina .= "</table>";

 $rodape = "

<table width='100%' style='vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;'>

<tr>
        <td width='33%'><span style='font-weight: bold; font-style: italic;'>{DATE d/m/Y}</span></td>
        <td width='33%' align='center' style='font-weight: bold; font-style: italic;'>{PAGENO}/{nbpg}</td>
        <td width='33%' style='text-align: right; '>Rio Med</td>
    </tr>
</table>
</body>
</html>

 ";

 date_default_timezone_set('America/Sao_Paulo');
    $date = date('d/m/Y H:i');

    $arquivo = $date." - Relatorio.pdf";

    $mpdf = new mPDF('utf-8', 'A4-L',7,'MS Serif',7,7,27,13);    



    $mpdf->SetDisplayMode('fullpage');

    $mpdf->SetHTMLHeader($topo,'0',true);

    $mpdf->SetHTMLFooter($rodape);

    $mpdf->AddPageByArray(array(

    'orientation' => 'L',

    'mgl' => '10',

    'mgr' => '10',

    'mgt' => '30',

    'mgb' => '20',

    'mgh' => '10',

    'mgf' => '10',

    ));


    $mpdf->writeHTML($corpo_pagina);

    $mpdf->Output($arquivo, 'I');
    exit();
    
asked by anonymous 02.12.2016 / 13:16

1 answer

0

As you are sending various data through a form using the POST request method, and as discussed in the comments, you need to configure the following directives in php.ini:

  • post_max_size ;
  • max_input_vars ;
  • max_execution_time .

post_max_size indicates the maximum size that can be used for data sent by POST. If you pass this size, the surplus data is ignored. Default 8M, increase to 128. link

max_input_vars indicates the maximum number of variables that can be sent from client to server (either in GET, POST or COOKIES). Default 1000, increase to 10000. link

As you increased the post_max_size and max_input_vars directives, your script began to take longer to run (you now have more variables for the report). This way, your script may start displaying timeout.

max_execution_time sets the maximum time a PHP script can run. Scripts such as reports can take longer than the normal query for a page. Default 30, increase as necessary. If time is varied, you can include 0 to be treated as "no limit". link

    
15.02.2017 / 11:29