<?php
/*
* ** General-use version DEBUG HINT: - Inside function printbuffer make $fill=1
* - Inside function Cell make: if($fill==1 or $border==1) { // if ($fill==1)
* $op=($border==1) ? 'B' : 'f'; // else $op='S'; $op='S'; - Following these 2
* steps you will be able to see the cell's boundaries WARNING: When adding a
* new tag support, also add its name inside the function DisableTags()'s very
* long string ODDITIES (?): . It seems like saved['border'] and
* saved['bgcolor'] are useless inside the FlowingBlock... These 2 attributes do
* the same thing?!?: . $this->currentfont - mine . $this->CurrentFont - fpdf's
* TODO (in the future...): - Make font-family, font-size, lineheight
* customizable - Increase number of HTML/CSS tags/properties, Image/Font Types,
* recognized/supported - allow BMP support? (tried with
* http://phpthumb.sourceforge.net/ but failed) - Improve CSS support - support
* image side-by-side or one-below-another or both? - Improve code clarity even
* more (modularize and get better var names like on textbuffer array's indexes
* for example)
* //////////////////////////////////////////////////////////////////////////////
* //////////////DO NOT MODIFY THE CONTENTS OF THIS
* BOX//////////////////////////
* //////////////////////////////////////////////////////////////////////////////
* // // // HTML2FPDF is a php script to read a HTML text and generate a PDF
* file. // // Copyright (C) 2004-2005 Renato Coelho // // This script may be
* distributed as long as the following files are kept // // together: // // //
* // fpdf.php, html2fpdf.php, gif.php,htmltoolkit.php,license.txt,credits.txt
* // // //
* //////////////////////////////////////////////////////////////////////////////
* Misc. Observations: - CSS + align = bug! (?) OBS1: para textos de mais de 1
* p�gina, talvez tenha que juntar varios $texto_artigo antes de mandar gerar o
* PDF, para que o PDF gerado seja completo. OBS2: there are 2 types of spaces
* 32 and 160 (ascii values) OBS3: //! is a special comment to be used with
* source2doc.php, a script I created in order to generate the doc on the site
* html2fpdf.sf.net OBS4: var $LineWidth; // line width in user unit - use this
* to make css thin/medium/thick work OBS5: Images and Textareas: when they are
* inserted you can only type below them (==display:block) OBS6: Optimized to
* 'A4' paper (default font: simsun , normal , size 11 ) OBS7: Regexp + Perl
* ([preg]accepts non-greedy quantifiers while PHP[ereg] does not) Perl:
* '/regexp/x' where x == option ( x = i:ignore case , x = s: DOT gets \n as
* well) ========================END OF INITIAL
* COMMENTS=================================
*/
define ( 'HTML2FPDF_VERSION', '3.0(beta)' );
if (! defined ( 'RELATIVE_PATH' ))
define ( 'RELATIVE_PATH', '' );
if (! defined ( 'FPDF_FONTPATH' ))
define ( 'FPDF_FONTPATH', 'font/' );
require_once ('chinese/chinese.php');
require_once ('htmltoolkit.php');
class HTML2FPDF extends PDF_Chinese {
// internal attributes
var $HREF; // ! string
var $pgwidth; // ! float
var $fontlist; // ! array
var $issetfont; // ! bool
var $issetcolor; // ! bool
var $titulo; // ! string
var $oldx; // ! float
var $oldy; // ! float
var $B; // ! int
var $U; // ! int
var $I; // ! int
var $tablestart; // ! bool
var $tdbegin; // ! bool
var $table; // ! array
var $cell; // ! array
var $col; // ! int
var $row; // ! int
var $divbegin; // ! bool
var $divalign; // ! char
var $divwidth; // ! float
var $divheight; // ! float
var $divbgcolor; // ! bool
var $divcolor; // ! bool
var $divborder; // ! int
var $divrevert; // ! bool
var $listlvl; // ! int
var $listnum; // ! int
var $listtype; // ! string
// array(lvl,# of occurrences)
var $listoccur; // ! array
// array(lvl,occurrence,type,maxnum)
var $listlist; // ! array
// array(lvl,num,content,type)
var $listitem; // ! array
var $buffer_on; // ! bool
var $pbegin; // ! bool
var $pjustfinished; // ! bool
var $blockjustfinished; // ! bool
var $SUP; // ! bool
var $SUB; // ! bool
var $toupper; // ! bool
var $tolower; // ! bool
var $dash_on; // ! bool
var $dotted_on; // ! bool
var $strike; // ! bool
var $CSS; // ! array
var $cssbegin; // ! bool
var $backupcss; // ! array
var $textbuffer; // ! array
var $currentstyle; // ! string
var $currentfont; // ! string
var $colorarray; // ! array
var $bgcolorarray; // ! array
var $internallink; // ! array
var $enabledtags; // ! string
var $lineheight; // ! int
var $basepath; // ! string
// array('COLOR','WIDTH','OLDWIDTH')
var $outlineparam; // ! array
var $outline_on; // ! bool
var $specialcontent; // ! string
var $selectoption; // ! array
// options attributes
var $usecss; // ! bool
var $usepre; // ! bool
var $usetableheader; // ! bool
var $shownoimg; // ! bool
function HTML2FPDF($orientation = 'P', $unit = 'mm', $format = 'A4') {
// ! @desc Constructor
// ! @return An object (a class instance)
// Call parent constructor
$this->FPDF ( $orientation, $unit, $format );
// To make the function Footer() work properly
$this->AliasNbPages ();
// Enable all tags as default
$this->DisableTags ();
// Set default display preferences
//$this->DisplayPreferences( '' );
$this->DisplayPreferences('');
// Initialization of the attributes
// $this->SetFont('simsun','',11); // Changeable?(not yet...)
$this->lineheight = 5; // Related to FontSizePt == 11
$this->pgwidth = $this->fw - $this->lMargin - $this->rMargin;
$this->SetFillColor ( 255 );
$this->HREF = '';
$this->titulo = '';
$this->oldx = - 1;
$this->oldy = - 1;
$this->B = 0;
$this->U = 0;
$this->I = 0;
$this->listlvl = 0;
$this->listnum = 0;
$this->listtype = '';
$this->listoccur = array ();
$this->listlist = array ();
$this->listitem = array ();
$this->tablestart = false;
$this->tdbegin = false;
$this->table = array ();
$this->cell = array ();
$this->col = - 1;
$this->row = - 1;
$this->divbegin = false;
$this->divalign = "L";
$this->divwidth = 0;
$this->divheight = 0;
$this->divbgcolor = false;
$this->divcolor = false;
$this->divborder = 0;
$this->divrevert = false;
$this->fontlist = array ("GB", "times", "courier", "helvetica", "symbol", "monospace", "serif", "sans" );
$this->issetfont = false;
$this->issetcolor = false;
$this->pbegin = false;
$this->pjustfinished = false;
$this->blockjustfinished = true; // in order to eliminate exceeding
// left-side spaces
$this->toupper = false;
$this->tolower = false;
$this->dash_on = false;
$this->dotted_on = false;
$this->SUP = false;
$this->SUB = false;
$this->buffer_on = false;
$this->strike = false;
$this->currentfont = '';
$this->currentstyle = '';
$this->colorarray = array ();
$this->bgcolorarray = array ();
$this->cssbegin = false;
$this->textbuffer = array ();
$this->CSS = array ();
$this->backupcss = array ();
$this->internallink = array ();
$this->basepath = "";
$this->outlineparam = array ();
$this->outline_on = false;
$this->specialcontent = '';
$this->selectoption = array ();
$this->shownoimg = false;
$this->usetableheader = false;
$this->usecss = true;
$this->usepre = true;
}
function setBasePath($str) {
// ! @desc Inform the script where the html file is (full path - e.g.
// http://www.google.com/dir1/dir2/dir3/file.html ) in order to adjust
// HREF and SRC links. No-Parameter: The directory where this script is.
// ! @return void
$this->basepath = dirname ( $str ) . "/";
$this->basepath = str_replace ( "\\", "/", $this->basepath ); // I