TCPDF
This is a PHP4 class for generating PDF files on-the-fly without requiring external extensions.
This class is an extension and improvement of the FPDF class by Olivier Plathey (http://www.fpdf.org).
This version contains some changes: [porting to PHP4, support for UTF-8 Unicode, code style and formatting, php documentation (www.phpdoc.org), ISO page formats, minor improvements, image scale factor]
TCPDF project (http://tcpdf.sourceforge.net) is based on the public Domain FPDF class by Olivier Plathey (http://www.fpdf.org).
To add your own TTF fonts please read /fonts/README.TXT
Located in /tcpdf/tcpdf.php (line 87)
TCPDF
TCPDF
TCPDF
([string $orientation = 'P'], [string $unit = 'mm'], [mixed $format = 'A4'], [boolean $unicode = true], [String $encoding = "UTF-8"])
void
Cell
(float $w, [float $h = 0], [string $txt = ''], [mixed $border = 0], [int $ln = 0], [string $align = ''], [int $fill = 0], [mixed $link = ''])
void
Image
(string $file, float $x, float $y, [float $w = 0], [float $h = 0], [string $type = ''], [mixed $link = ''])
int
MultiCell
(float $w, float $h, string $txt, [mixed $border = 0], [string $align = 'J'], [int $fill = 0], [int $ln = 1])
void
writeBarcode
(int $x, int $y, int $w, int $h, string $type, string $style, string $font, int $xres, string $code)
void
writeHTMLCell
(float $w, float $h, float $x, float $y, [string $html = ''], [mixed $border = 0], [int $ln = 0], [int $fill = 0])
alias
$AliasNbPages
(line 430)
author
$author
(line 412)
automatic
$AutoPageBreak
(line 370)
page
$bMargin
(line 226)
buffer
$buffer
(line 112)
cell
$cMargin
(line 232)
indicates
$ColorFlag
(line 358)
compression
$compress
(line 130)
array
$CoreFonts
(line 262)
creator
$creator
(line 424)
current
$CurOrientation
(line 142)
current
$CurrentFont
(line 322)
default
$DefOrientation
(line 136)
array
$diffs
(line 280)
commands
$DrawColor
(line 340)
height
$fh
(line 178)
height
$fhPt
(line 166)
commands
$FillColor
(line 346)
current
$FontFamily
(line 304)
array
$FontFiles
(line 274)
array
$fonts
(line 268)
current
$FontSize
(line 334)
current
$FontSizePt
(line 328)
current
$FontStyle
(line 310)
width
$fw
(line 172)
width
$fwPt
(line 160)
current
$h
(line 202)
current
$hPt
(line 190)
array
$images
(line 286)
image
$imgscale
= 1 (line 454)
right-bottom
$img_rb_x
(line 438)
right-bottom
$img_rb_y
(line 446)
flag
$InFooter
(line 382)
boolean
$isunicode
= false (line 462)
scale
$k
(line 154)
keywords
$keywords
(line 418)
height
$lasth
(line 250)
layout
$LayoutMode
(line 394)
line
$LineWidth
(line 256)
array
$links
(line 298)
left
$lMargin
(line 208)
current
$n
(line 100)
array
$offsets
(line 106)
array
$OrientationChanges
(line 148)
current
$page
(line 94)
threshold
$PageBreakTrigger
(line 376)
array
$PageLinks
(line 292)
array
$pages
(line 118)
PDF
$PDFVersion
= "1.3" (line 469)
right
$rMargin
(line 220)
current
$state
(line 124)
subject
$subject
(line 406)
commands
$TextColor
(line 352)
title
$title
(line 400)
top
$tMargin
(line 214)
underlining
$underline
(line 316)
current
$w
(line 196)
current
$wPt
(line 184)
word
$ws
(line 364)
current
$x
(line 238)
current
$y
(line 244)
zoom
$ZoomMode
(line 388)
This is the class constructor.
It allows to set up the page format, the orientation and the measure unit used in all the methods (except for the font sizes).
-
string
$orientation: page orientation. Possible values are (case insensitive):
- P or Portrait (default)
- L or Landscape
-
string
$unit: User measure unit. Possible values are:
- pt: point
- mm: millimeter (default)
- cm: centimeter
- in: inch
A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit. -
mixed
$format: The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).
- 4A0
- 2A0
- A0
- A1
- A2
- A3
- A4 (default)
- A5
- A6
- A7
- A8
- A9
- A10
- B0
- B1
- B2
- B3
- B4
- B5
- B6
- B7
- B8
- B9
- B10
- C0
- C1
- C2
- C3
- C4
- C5
- C6
- C7
- C8
- C9
- C10
- RA0
- RA1
- RA2
- RA3
- RA4
- SRA0
- SRA1
- SRA2
- SRA3
- SRA4
- LETTER
- LEGAL
- EXECUTIVE
- FOLIO
- boolean $unicode: TRUE means that the input text is unicode (default = true)
- String $encoding: charset encoding; default is UTF-8
Whenever a page break condition is met, the method is called, and the break is issued or not depending on the returned value. The default implementation returns a value according to the mode selected by SetAutoPageBreak().
This method is called automatically and should not be called directly by the application.
Example:
The method is overriden in an inherited class in order to obtain a 3 column layout:
class PDF extends TCPDF {
var $col=0;
function SetCol($col) {
//Move position to a column
$this->col=$col;
$x=10+$col*65;
$this->SetLeftMargin($x);
$this->SetX($x);
}
function AcceptPageBreak() {
if($this->col<2) {
//Go to next column
$this->SetCol($this->col+1);
$this->SetY(10);
return false;
}
else {
//Go back to first column and issue page break
$this->SetCol(0);
return true;
}
}
}
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial','',12);
for($i=1;$i<=300;$i++) {
$pdf->Cell(0,5,"Line $i",0,1);
}
$pdf->Output();
Imports a TrueType or Type1 font and makes it available. It is necessary to generate a font definition file first with the makefont.php utility. The definition file (and the font file itself when embedding) must be present either in the current directory or in the one indicated by FPDF_FONTPATH if the constant is defined. If it could not be found, the error "Could not include font definition file" is generated.
Support UTF-8 Unicode [Nicola Asuni, 2005-01-02]. Example:
$pdf->AddFont('Comic','I');
// is equivalent to:
$pdf->AddFont('Comic','I','comici.php');



TCPDF