php将页面下载成pdf
简介php将页面下载成pdf,保存页面信息
调用代码:
public function pdf(){
$id = $_REQUEST['id'];
//根据实际情况而定 $data =M('teacher')->alias('a')->field('a.id,a.ability,a.name,a.title,a.sex,a.year,a.cardid,a.address,a.phone,a.img,a.uploadpath,b.content,b.experience,b.honor')->join('left join cmf_teacher_detail b on a.id=b.teacher_id')
->where(array('id'=>$id))->find();
$this->assign('data',$data);
//引入类库
Vendor('mpdf.mpdf');
//设置中文编码
$mpdf=new \mPDF('zh-cn','A4', 0, '宋体', 0, 0);
$mpdf->SetWatermarkText('中国水印',0.1);
$html = $this->fetch();
$mpdf->WriteHTML($html);
$mpdf->Output('a.pdf',true);
$mpdf->Output('a.pdf',D);
$mpdf->Output();
}

浙公网安备 33010602011771号