HI I have a working MPDF that generates a PDF from an html php file. The only problem I have is it automatically downloads the PDF file instead of showing a print PDF view in the browser. How can I achieve that?
So this is currently my MY_pdf.php file in the libraries.
include_once APPPATH.'/third_party/mpdf/mpdf.php';
class MY_pdf {
public $param;
public $pdf;
public function __construct($param = '"en-GB-x","A4","","",10,10,10,10,6,3')
{
$this->param =$param;
$this->pdf = new mPDF($this->param);
}
function AliasNbPages($alias='{nb}') {
//Define an alias for total number of pages
$this->aliasNbPg=$alias;
}
function getPageCount() {
return count($this->pages);
}
}
I assume this is just an extension in the libraries, so here is the main part in the controller where I call the MPDF.
Controller:
public function printmembers()
{
$this->load->model('mdladmin');
$data['mem'] = $this->mdladmin->get_members();
$html=$this->load->view('printmembersmasterlist', $data, true);
//load mPDF library
$this->load->library('MY_pdf');
//generate the PDF from the given html
$this->my_pdf->pdf->WriteHTML($html);
//download it.
$this->my_pdf->pdf->Output();
}