PHP实现生成PDF文件的方法基于FPDF类库
首先要下载FPDF,网址:http://www.fpdf.org/,或者点击此处本站下载。
例子:将下面的文件保存在web根目录,与附件fpdf17处于同一级
<?php ini_set('display_errors', '0'); ini_set('max_execution_time', '60'); require ('fpdf17/chinese.php'); $pdf = new PDF_Chinese(); $pdf->AddGBFont(); $pdf->Open(); $pdf->AddPage(); $pdf->SetFont('GB', 'B', 10); $pdf->SetLeftMargin(15.0); $pdf->Cell(180, 8, iconv("UTF-8", "gbk", "2015年10月出勤统计表 导出时间: 2015-10-14 市场部3人"), 1, 0, 'C'); $pdf->Ln(); //以上是表头 $pdf->SetFont('GB', '', 8); $pdf->SetLeftMargin(15.0); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "UID"), 1, 0, 'C'); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "姓名"), 1, 0, 'C'); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "部门"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "出勤/天"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "出勤/小时"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "迟到/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "迟到/分钟"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/分钟"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "缺卡/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "地点异常/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "账号状态"), 1, 0, 'C'); $pdf->Ln(); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "10002"), 1, 0, 'C'); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "市场部"), 1, 0, 'C'); $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "1"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "9.0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C'); $pdf->Ln(); $pdf->Output(); ?>
原文链接:https://blog.csdn.net/shaobingj126/article/details/49150129
(资源库 www.zyku.net)
您可能感兴趣的文章
- 03-10pdf.js使用教程
- 03-14华为freebuds4唤醒小艺方法
- 11-30google photos更改中文步骤介绍
- 04-01vivos9切换系统操作方法
- 03-04wordpress防黑教程之保护登录文件wp-l
- 02-19简单粗暴的Redis数据备份和恢复方法
- 01-08vivox70怎么关闭横屏
- 03-04Apple Music无损音乐设置方法
- 11-01ipad怎么设置一键锁屏
- 11-26autosleep重新播放介绍教程分享
- 01-11鼎晟出行-鼎晟出行应用软件功能介绍
- 02-15小米手机定时开启护眼模式设置教程
- 09-23vivox70如何设置自动锁屏
- 01-18时光流影-时光流影应用软件功能介绍
- 08-15evEcoStudio取消分隔符显示教程分享
- 01-11棒棒哒音乐-棒棒哒音乐应用软件功能介
- 05-05excel表格中自动生成手机号码
- 07-04帝国CMS7.5版多访问端新增静态页面同
- 01-12ToSee-ToSee应用软件功能介绍
- 10-21oppowatch2连接手机教程介绍
最近更新
阅读排行
猜你喜欢
- 02-13将pytorch的网络等转移到cuda
- 09-11高德地图实名认证教程分享
- 01-29红米note9pro拍照打开夜景模式方法
- 01-13时尚编辑器-时尚编辑器应用软件功能介
- 02-16Vim 多行剪切、复制和删除功能
- 01-14万小能遥控器-万小能遥控器应用软件功
- 01-11小马菜谱-小马菜谱应用软件功能介绍
- 03-15WordPress占用资源过大 一般的优化方
- 02-23DedeCMS还原数据时其他表的数据自动清
- 02-10Python自动化之定位方法大杀器xpath