mpdf / mpdf.github.io

mPDF documentation
https://mpdf.github.io
Other
509 stars 160 forks source link

MPDF Break page #118

Closed FM57 closed 5 years ago

FM57 commented 5 years ago

Hello,

I read many of the PageBreak recommendations but it just does not work for me

My edited code `<?php // Require composer autoload require_once DIR . '/vendor/autoload.php'; // Create an instance of the class: $mpdf = new \Mpdf\Mpdf();

//Set Header $mpdf->SetHTMLHeader('

    <div>'.$data_2.'</div>
</div>

<div class="pageHeaderRight">Date:'.$data_4.'
</div>

<div class="pageHeaderRight2">
    <div>'.$data_3.'</div>
</div>

<div class="pageOffer">
    <div>OFFRE DE PRIX N°'.$data_5.'</div>
</div>

');

//Set Footer $mpdf->SetHTMLFooter('


{PAGENO} ');

$main='!DOCTYPE html>

Offre de Prix
'; $ligneDesc = explode("

",$data_8); $nbLignes = count($ligneDesc); $ligneBreak = substr_count($data_8,"
"); $totalLignes = $nbLignes+$ligneBreak; for ($i=0; $i<$nbLignes; $i++) { $ligneDesc[$i] = $ligneDesc[$i]."

"; } for ($index = 0;$index < $nbLignes; ++$index) { if (($index+$ligneBreak) == 100) { //$main =$main.'
'; $totalLignes = 0; } $main = $main.$ligneDesc[$index]; $totalLignes +=1; } $main =$main.'
'; // Write some HTML code: $mpdf->WriteHTML($main); // Output a PDF file directly to the browser $mpdf->SetTitle($data_5); $mpdf->Output($data_5.'.pdf', 'I'); try { $mpdf->Output(); } catch (\Mpdf\MpdfException $e) { // Note: safer fully qualified exception name used for catch // Process the exception, log, print etc. echo $e->getMessage(); } ?>` ![Capture](https://user-images.githubusercontent.com/32942732/59195722-fb575e00-8b8c-11e9-86fd-777ab6f732ce.PNG) gives me the full text I want to display with no wrap, which is OK. But as soon as I want to add a pagebreak if a condition is filled (say 100 lines of text), then nothing is displayed on the screen except the footer and header. All the $data_x are correctly given, and printed. Only the pageBreak gives me a headache. I use `$main =$main.'
';` in the condition to add the needed break but it just des not do it. Thanks for the support
finwe commented 5 years ago

Please note that the Issue tracker serves mainly as a place to report bugs and request new features as noted in Contributing guidelines. Please do not abuse it as a general questions or troubleshooting location.

Use the the mpdf tag at Stack Overflow.