function tcpdf($data){
require '../extend/tcpdf/tcpdf.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetTitle($data['title']);
$pdf->setPrintHeader(false); //页面头部横线取消
$pdf->setPrintFooter(false); //页面底部更显取消
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);//自动分页
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);//设置页面margin
$pdf->SetFont('stsongstdlight', '', 12);//设置字体,注意在循环里面一定要把new都一起放在循环里面,不然会报错,没有设置字体,因为这个需要上下文来读取配置
$pdf->AddPage();//增加一个页面
$pdf->setCellPaddings(0, 0, 0, 0);//设置一个单元格的padding
$contract_content = $data['html'];
$pdf->writeHTML($contract_content, $ln = true, $fill = false, $reseth = false, $cell = false, $align = '1');
//PDF输出 I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串
$pdf->Output('aa.pdf', 'D');
}
$data = array(
'title'=>'标题',
‘html’=>html页面
);
需要下载tcpdf。