程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php生成pdf文件代碼(1/12)

php生成pdf文件代碼(1/12)

編輯:關於PHP編程

php生成pdf文件代碼生成pdf文件如果真的生成很好,是很復雜的,下面我們來看看一款完整理的php生成pdf文件代碼吧,他可以把文本文件生成pdf文件也可以利用圖片文件生成pdf文件哦。

<?
//php教程生成pdf文件代碼
/*
生成pdf文件如果真的生成很好,是很復雜的,下面我們來看看一款完整理的php生成pdf文件代碼吧,他可以把文本文件生成pdf文件也可以利用圖片文件生成pdf文件哦。

這款生成pdf文件用到文件有
fpdf.php
chinese.php
picpdf.php

*/
//fpdf.php代碼

define('fpdf_version','1.6');

class fpdf
{
var $page;               //current page number
var $n;                  //current object number
var $offsets;            //array of object offsets
var $buffer;             //buffer holding in-memory pdf
var $pages;              //array containing pages
var $state;              //current document state
var $compress;           //compression flag
var $k;                  //scale factor (number of points in user unit)
var $deforientation;     //default orientation
var $curorientation;     //current orientation
var $pageformats;        //available page formats
var $defpageformat;      //default page format
var $curpageformat;      //current page format
var $pagesizes;          //array storing non-default page sizes
var $wpt,$hpt;           //dimensions of current page in points
var $w,$h;               //dimensions of current page in user unit
var $lmargin;            //left margin
var $tmargin;            //top margin
var $rmargin;            //right margin
var $bmargin;            //page break margin
var $cmargin;            //cell margin
var $x,$y;               //current position in user unit
var $lasth;              //height of last printed cell
var $linewidth;          //line width in user unit
var $corefonts;          //array of standard font names
var $fonts;              //array of used fonts
var $fontfiles;          //array of font files
var $diffs;              //array of encoding differences
var $fontfamily;         //current font family
var $fontstyle;          //current font style
var $underline;          //underlining flag
var $currentfont;        //current font info
var $fontsizept;         //current font size in points
var $fontsize;           //current font size in user unit
var $drawcolor;          //commands for drawing color
var $fillcolor;          //commands for filling color
var $textcolor;          //commands for text color
var $colorflag;          //indicates whether fill and text colors are different
var $ws;                 //word spacing
var $images;             //array of used images
var $pagelinks;          //array of links in pages
var $links;              //array of internal links
var $autopagebreak;      //automatic page breaking
var $pagebreaktrigger;   //threshold used to trigger page breaks
var $inheader;           //flag set when processing header
var $infooter;           //flag set when processing footer
var $zoommode;           //zoom display mode
var $layoutmode;         //layout display mode
var $title;              //title
var $subject;            //subject
var $author;             //author
var $keywords;           //keywords
var $creator;            //creator
var $aliasnbpages;       //alias for total number of pages
var $pdfversion;         //pdf version number

/*******************************************************************************
*                                                                              *
*                               public methods                                 *
*                                                                              *
*******************************************************************************/
function fpdf($orientation='p', $unit='mm', $format='a4')
{
 //some checks
 $this->_dochecks();
 //initialization of properties
 $this->page=0;
 $this->n=2;
 $this->buffer='';
 $this->pages=array();
 $this->pagesizes=array();
 $this->state=0;
 $this->fonts=array();
 $this->fontfiles=array();
 $this->diffs=array();
 $this->images=array();
 $this->links=array();
 $this->inheader=false;
 $this->infooter=false;
 $this->lasth=0;
 $this->fontfamily='';
 $this->fontstyle='';
 $this->fontsizept=12;
 $this->underline=false;
 $this->drawcolor='0 g';
 $this->fillcolor='0 g';
 $this->textcolor='0 g';
 $this->colorflag=false;
 $this->ws=0;
 //standard fonts
 $this->corefonts=array('courier'=>'courier', 'courierb'=>'courier-bold', 'courieri'=>'courier-oblique', 'courierbi'=>'courier-boldoblique',
  'helvetica'=>'helvetica', 'helveticab'=>'helvetica-bold', 'helveticai'=>'helvetica-oblique', 'helveticabi'=>'helvetica-boldoblique',
  'times'=>'times-roman', 'timesb'=>'times-bold', 'timesi'=>'times-italic', 'timesbi'=>'times-bolditalic',
  'symbol'=>'symbol', 'zapfdingbats'=>'zapfdingbats');
 //scale factor
 if($unit=='pt')1 2 3 4 5 6 7 8 9 10 11 12

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved