php實(shí)現(xiàn)生成PDF文件的方法示例【基于FPDF類庫】
本文實(shí)例講述了php實(shí)現(xiàn)生成PDF文件的方法。分享給大家供大家參考,具體如下:
首先要下載FPDF http://www.fpdf.org/
或者點(diǎn)擊此處本站下載。
例子:將下面的文件保存在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月出勤統(tǒng)計表 導(dǎo)出時間: 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", "地點(diǎn)異常/次"), 1, 0, 'C'); $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "賬號狀態(tài)"), 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(); ?>
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php文件操作總結(jié)》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計算法總結(jié)》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》及《php字符串(string)用法總結(jié)》
希望本文所述對大家PHP程序設(shè)計有所幫助。
相關(guān)文章
PHP自帶方法驗(yàn)證郵箱、URL、IP是否合法的函數(shù)
以前用PHP驗(yàn)證郵箱、URL、IP是否合法都是通過自己寫正則來實(shí)現(xiàn),但是有時候腦子發(fā)昏,可能會寫出一個不是完全正確的正則,導(dǎo)致驗(yàn)證出錯,今天發(fā)現(xiàn)原來PHP本身自帶了驗(yàn)證郵箱、URL、IP是否合法的函數(shù)2016-12-12Zend studio for eclipse中使php可以調(diào)用mysql相關(guān)函數(shù)的設(shè)置方法
默認(rèn)情況zend studio 中的php是不支持mysql 相關(guān)操作,但通過下面的方法即可解決2008-10-10淺析關(guān)于PHP位運(yùn)算的簡單權(quán)限設(shè)計
本篇文章是對PHP位運(yùn)算的簡單權(quán)限設(shè)計進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06