0
I’m trying to break a page with mPDF and PHP by changing the ID of the record, my information is on a table, but I do not know how to do, because my attempts with the $mpdf->AddPage(); failed.
I wish that whenever $RegMaloteExiste->NumeroMalote; were different occurs page break, something like:
First I created a variable that receives the number of ID:
$IdNumMalote = $RegMaloteExiste->NumeroMalote;
Then, already in the code that generates the PDF I did this:
if ($IdNumMalote != $RegMaloteExiste) {
$mpdf->AddPage();
}
Even breaks the page, but with content not, I know that the mPDF has some limitations with tables but I don’t know if this is one of those cases.
A picture of the report I have:
The code with html and php:
Part that generates the PDF:
$html = ob_get_clean();
ob_end_clean(); // Finaliza o fluxo
$IdNumMalote = $RegMaloteExiste->NumeroMalote;
include("../../../_comp/externos/MPDF57/mpdf.php");
// cria um novo container PDF no formato A4 com orientação customizada
$mpdf=new mPDF('pt','A4',3,'',8,8,5,14,9,9,'P');
// muda o charset para aceitar caracteres acentuados iso 8859-1 utilizados por mim no banco de dados e na geracao do conteudo PHP com HTML
$mpdf->allow_charset_conversion=true;
$mpdf->charset_in='utf-8';
//Algumas configurações do PDF
$mpdf->SetDisplayMode('fullpage');
// modo de visualização
$cabecalho = "
Relatório Malote/Envelope - {DATE j/m/Y}
Página: {PAGENO}
";
$mpdf->SetHTMLHeader($cabecalho);
$rodape = '{DATE j/m/Y H:i}|{PAGENO}/{nb}| Intranet COCARI';
$mpdf->SetFooter($rodape);
// carrega uma folha de estilo - MAGICA!!!
$stylesheet1 = file_get_contents('../../../_comp/externos/bootstrap3/css/bootstrap.min.css');
$stylesheet2 = file_get_contents('../../../_css/stgeral.css');
// incorpora a folha de estilo ao PDF
// O parâmetro 1 diz que este é um css/style e deverá ser interpretado como tal
$mpdf->WriteHTML($stylesheet1,1);
$mpdf->WriteHTML($stylesheet2,1);
// incorpora o corpo ao PDF na posição 2 e deverá ser interpretado como footage. Todo footage é posicao 2 ou 0(padrão).
$mpdf->WriteHTML($html,2);
if ($IdNumMalote != $RegMaloteExiste) {
$mpdf->AddPage();
}
// define um nome para o arquivo PDF
$arquivo = 'ControleMalote.pdf';
// gera o relatório
$mpdf->Output($arquivo,'I');
exit();


If you have the whole code?
– novic
Hello @Virgilionovic, I can’t put the whole code, I have html and php together.
– adventistapr
By chance an Addpage was given and created a table for each item?
– novic
Hello @Virgilionovic, I made the Addpage inside my IF and for each item has a table.
– adventistapr
You have to make the complete table for each item and in the break you send to another page... I think that’s it.
– novic