我有一个可以从html php文件生成PDF的MPDF。我唯一的问题是它自动下载PDF文件而不是在浏览器中显示打印PDF视图。我怎样才能做到这一点?
所以这是我目前在库中的MY_pdf.php文件。
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);
}
}
我认为这只是库中的扩展,所以这是我称之为MPDF的控制器中的主要部分。
控制器:
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();
}