Home >Backend Development >PHP Tutorial >PHP generate pdf file code (1/12)_PHP tutorial

PHP generate pdf file code (1/12)_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:18946browse

The php code to generate pdf files is very complicated if it is really good at generating pdf files. Let's take a look at a complete php code to generate pdf files. It can generate pdf files from text files and can also use image files. Generate pdf file.

//php tutorial code to generate pdf files
/*
Generating pdf files is very complicated if it is really good. Let’s take a look at a complete PHP generates pdf file code. It can generate pdf files from text files or use image files to generate pdf files.

The files used to generate pdf files are
fpdf.php
chinese.php
picpdf.php

*/
//fpdf.php code

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444878.htmlTechArticlephp生成pdf文件代码生成pdf文件如果真的生成很好,是很复杂的,下面我们来看看一款完整理的php生成pdf文件代码吧,他可以把文本文件生成...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn