PHP高级html转pdf (MPDF)这里使用的扩展是 MPDF, 下载地址:mpdf 相关代码 include('./module/mpdf/Mpdf.php'); $mpdf = new mpdf('zh-CN'); $mpdf->useAdobeCJK = true; // $mpdf->SetHTMLHeader(""); $mpdf->SetDisplayMode('fullpage'作者王明昌发布时间2019-07-03最后更新2019-07-03 这里使用的扩展是 MPDF, 下载地址:mpdf 相关代码 复制include('./module/mpdf/Mpdf.php'); $mpdf = new mpdf('zh-CN'); $mpdf->useAdobeCJK = true; // $mpdf->SetHTMLHeader(""); $mpdf->SetDisplayMode('fullpage'); $url = 'http://demo.wangingchang.com/sssss.html'; $strContent = file_get_contents($url); $mpdf->showWatermarkText = true; $mpdf->WriteHTML($strContent); $mpdf->Output(); //直接输出pdf内容 //$mpdf->Output('tmp.pdf',true);//保存成pdf文件 一些高级用法 复制$mpdf=new \mPDF('zh-cn','A4', 0, '宋体', 0, 0); $mpdf->SetWatermarkText('中国水印',0.1); $strContent = '我是带水印的PDF文件'; $mpdf->showWatermarkText = true; $mpdf->SetHTMLHeader( '头部' ); $mpdf->SetHTMLFooter( '底部' ); //$stylesheet =file_get_contents('themes/wei/css/bootstrap.min.css'); //$mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($strContent); //保存ss.pdf文件 $mpdf->Output('ss.pdf'); //直接浏览器输出pdf $mpdf->Output('tmp.pdf',true); $mpdf->Output('tmp.pdf','d'); $mpdf->Output(); 其他: 复制//实例化 $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); // 设置文档信息 $pdf->SetCreator('51ask'); $pdf->SetAuthor('51ask'); $pdf->SetTitle('知了PHP问答社区'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, PHP'); // 设置页眉和页脚信息 $pdf->SetHeaderData('logo.png', 30, '51ask.org', 'IT问答', array(0,64,255), array(0,64,128)); //设置版权信息(水印) $pdf->setFooterData(array(0,64,0), array(0,64,128)); // 设置页眉和页脚字体 $pdf->setHeaderFont(Array('stsongstdlight', '', '10')); $pdf->setFooterFont(Array('helvetica', '', '8')); // 设置默认等宽字体 $pdf->SetDefaultMonospacedFont('courier'); // 设置间距 $pdf->SetMargins(15, 27, 15); $pdf->SetHeaderMargin(5); $pdf->SetFooterMargin(10); // 设置分页 $pdf->SetAutoPageBreak(TRUE, 25); // set image scale factor $pdf->setImageScale(1.25); // set default font subsetting mode $pdf->setFontSubsetting(true); //设置字体 $pdf->SetFont('stsongstdlight', '', 14); $pdf->AddPage(); $str = '欢迎来到51ask.org'; $pdf->Write(0,$str,'', 0, 'L', true, 0, false, false, 0); //输出PDF $pdf->Output('demo.pdf', 'I'); 简单总结点: mpdf 对HTML相比之下比较友好
2018-08-22支付宝支付接口错误说明错误查询 https://docs.open.alipay.com/58/103599/ 今天我遇到的一个错误,经过询问小二,网关错误,错误如下 ILLEGAL_ACCESS_SWITCH_SYSTE
2019-12-10阿里巴巴开源镜像提供的 packagist 镜像服务全局配置(推荐) 所有项目都会使用该镜像地址: composer config -g repo.packagist composer https://mirrors.aliyun.com/compos
2018-08-26实例 | 支付宝支付(使用md5加密)参数的获取 pid|key获取: 商户中心---账户管理---查看pid|key https://openhome.alipay.com/platform/keyManage.htm?keyType=
2018-10-31实例 | tp5使用七牛云上传图片和文件/删除文件thinkphp5中使用七牛云 下载 https://github.com/qiniu/php-sdk vendor文件下 新建文件 application/extra/qiniu.php retur
2018-05-28ajax-post传值的写法var data = {type:type,is_ok:is_ok,id:id}; $("#train").on("click",function(){ var id = $("#id_res").v
2018-05-27Ajax异步搜索内容,并显示使用ajax异步搜索内容,如果符合内容,则一行行的显示,每次查询时清空上次的记录 $("#search").on("click",function(){ var key = $("#keywords"