Below an example working with mPDF with codeigniter, in case I import PDF controller, and send $data to the views report/pdf/body and report/pdf/body, where I store the PHP that will generate the HTML view with my information. Then just write to the file.
Detail $result is a Codeigniter Query result
$this->load->library('pdf');
$pdf = $this->pdf->load();
$data['titulo_relatorio'] = 'Relatório';
$header = $this->load->view('relatorio/pdf/header', $data, true);
$pdf->SetHTMLHeader($header);
$pdf->SetFooter('Titulo Relatório' . '|Página {PAGENO}|' . date("d.m.Y") . ' ');
$dataResult['result'] = $result;
$pdf->WriteHTML($this->load->view('relatorio/pdf/body', $dataResult, true));
$pdf->Output($pdfFilePath, 'I');
And below an example of the view code
<div>
<table>
<tr>
<th>COLUNA 1</th>
<th>COLUNA 2/th>
</tr>
<?php
foreach ($result as $row) {
?>
<tr>
<td><?php echo $row['campo1']; ?></td>
<td><?php echo $row['campo2']; ?></td>
</tr>
<?php
}
?>
</table>
</div>
In short, basically you will generate HTML and write it in a PDF file
mPDF is good, but for safety think about generating in XLS format because companies need to manipulate the data, and with pdf becomes complicated.
– Sveen