php实现生成PDF文件的方法示例【基于FPDF类库】

yipeiwu_com5年前PHP代码库

本文实例讲述了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();
?>

更多关于PHP相关内容感兴趣的读者可查看本站专题:《php文件操作总结》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《PHP数组(Array)操作技巧大全》、《PHP数据结构与算法教程》、《php程序设计算法总结》、《PHP数学运算技巧总结》及《php字符串(string)用法总结

希望本文所述对大家PHP程序设计有所帮助。

相关文章

php下正则来匹配dede模板标签的代码

html代码 复制代码 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w...

PHP CURL post数据报错 failed creating formpost data

在做微信卡券使用curl上传logo图片时,发现一个报错: failed creating formpost data 代码中数组如下: $data = array('buffer...

PHP图像处理技术实例总结【绘图、水印、验证码、图像压缩】

PHP图像处理技术实例总结【绘图、水印、验证码、图像压缩】

本文实例总结了PHP图像处理技术。分享给大家供大家参考,具体如下: 1、绘图 场景: 验证码、图像水印、图像压缩处理 php绘图坐标体系是从0,0点越向右值越大,越向下值越大 需要开启p...

Windows2003下php5.4安装配置教程(IIS)

Windows2003下php5.4安装配置教程(IIS)

本文与《Windows2003下php5.4安装配置教程(Apache2.4)》(点击打开链接)为姊妹篇,只是php所用的服务器有点不同,这里一个是Apache2.4,一个是Window...

Eclipse中php插件安装及Xdebug配置的使用详解

Eclipse中php插件安装及Xdebug配置的使用详解

由于在android开发团队,又迷上了android自动化测试,所有一直使用Eclipse做为开发工具。以前使用Zend Studio 9.0.1做为PHP的开发工具,现在放弃使用Zen...