php实现生成PDF文件的方法示例【基于FPDF类库】
发布:smiling 来源: PHP粉丝网 添加日期:2021-10-19 19:29:21 浏览: 评论:0
这篇文章主要介绍了php实现生成PDF文件的方法,结合实例形式分析了php基于FPDF类库实现生成pdf文件的相关操作技巧,需要的朋友可以参考下。
本文实例讲述了php实现生成PDF文件的方法,分享给大家供大家参考,具体如下:
首先要下载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();
- ?>
Tags: php实现生成PDF FPDF类库
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)