Below an example working with mPDF with codeigniter, in case I import PDF driver, and sending $ date to the report / pdf / body and report / pdf / body , in which I store PHP that will generate the view in HTML with my information. Then just write to the file.
Detail $ result is a result of Codeigniter's Query
$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 is an example of the view's 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