Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large data tables on MPDF - Can i avoid resize?

Tags:

php

mpdf

I'm generating some reports on my admin and I'm exporting to PDF using the MPDF library. But when this has a very large amount of data, MPDF is resizing the table to fit on page, so that it becomes awkward.

enter image description here

Is there any way to prevent this from happening? The code I am using to generate is the below. I've tried to set "shrink_tables_to_fit" to 0 and 1, both unsuccessful. Also tried to set autosize=1 to every table.

$stylesheet = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/site/css/layout/pdf.css');
$bootstrap = file_get_contents('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css');

$mpdf = new mPDF('pt', 'a4');

$mpdf->shrink_tables_to_fit = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';

$mpdf->SetHTMLHeader('<img src="'.$_SERVER['DOCUMENT_ROOT'].'/site/img/content/pdf/header.jpg">');
$mpdf->SetFooter('{DATE j/m/Y H:i}|{PAGENO}/{nb}');

$mpdf->WriteHTML($bootstrap, 1);
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html);

$mpdf->Output($_SERVER['DOCUMENT_ROOT'].'/upload/consultas-pre/'.$nomeArquivo.'.pdf', 'F');
like image 741
Maykel Esser Avatar asked Oct 18 '25 14:10

Maykel Esser


1 Answers

I found it.

I can not have a table with other tables inside. When this happens, MPDF gets lost in resize.

like image 63
Maykel Esser Avatar answered Oct 21 '25 03:10

Maykel Esser