I don't know how current code should look like, because i don't know much about mPDF, but i would suggest you to use domPdf with Codeigniter, because is much simpler then this library.
You can find domPdf here
Since we don't know what is the output for those variables and what should be printed in pdf, i can only suggest some generally code created with domPdf
create helper:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename='', $stream=TRUE){
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->set_paper("A4");
if ($stream) {
$dompdf->stream($filename.".pdf",1);
} else {
return $dompdf->output();
}
}
?>
create controller for pdf
<?php
$data['store']=$res;
$this->load->helper(array('dompdf', 'file'));
$html = $this->load->view('store/sales_pdf', $data, true);
$html.= $this->load->view('footer');
$filename="salesbill".$id;
pdf_create($html, $filename);
$data = pdf_create($html, '', false);
write_file('name', $data);
?>
And your pdf HTML would look something like this
<html>
<head>
<style>
@page { margin: 180px 50px; }
#header { position: fixed; left: 0px; top: -180px; right: 0px; height: 150px; background-color: orange; text-align: center; }
#footer { position: fixed; left: 0px; bottom: -180px; right: 0px; height: 150px; background-color: lightblue; }
#footer .page:after { content: counter(page, upper-roman); }
</style>
<body>
<div id="header">
<h1>Widgets Express</h1>
</div>
<div id="footer">
<p class="page">Page <?php $PAGE_NUM ?></p>
</div>
<div id="content">
<p>the first page</p>
<p style="page-break-before: always;">the second page</p>
</div>
</body>
</html>
This answer is based on this stackoverflow question
Also here is nice domPdf debug helper page
I hope this answer helps you out
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…