Document: ezcDocumentPdfTcpdfDriver
[ ]
[ Conversion ] [ Styles ]
[ ]
[ ]
[ ]
[ ]
Class: ezcDocumentPdfTcpdfDriver
|
Pdf driver based on TCPDF [
source]
TCPDF is a PHP based PDF renderer, originally based on FPDF and available at http://tcpdf.org.
The TCPDF class has to be loaded before this driver can be used. TCPDF has some bad coding practices, like:
- Throws lots of warnings and notices, which you might want to silence by
temporarily changing the error reporting level
- Reads and writes several global variables, which might or might not
interfere with your application code
- Uses eval() in several places, which results in non-cacheable OP-Codes.
The driver can be used by setting the respective option on the PDF document wrapper:
Parents
ezcDocumentPdfDriver
|
--ezcDocumentPdfTcpdfDriver
Inherited Constants
From
ezcDocumentPdfDriver:
Member Variables
|
protected array |
$currentFont
= array( 'name' => 'sans-serif', 'style' => self::FONT_PLAIN, 'size' => 12, )
Name and style of default font / currently used font |
|
protected haruPage |
$currentpage
Reference to the page currently rendered on |
|
protected Tcpdf |
$document
Tcpdf Document instance |
|
protected array |
$fonts
= array( 'sans-serif' => array( self::FONT_PLAIN => 'times', self::FONT_BOLD => 'timesb', self::FONT_OBLIQUE => 'timesi', 3 => 'timesbi', ),'serif'=>array(self::FONT_PLAIN=>'helvetica',self::FONT_BOLD=>'helveticab',self::FONT_OBLIQUE=>'helveticai',3=>'helveticabi',),'monospace'=>array(self::FONT_PLAIN=>'courier',self::FONT_BOLD=>'courierb',self::FONT_OBLIQUE=>'courieri',3=>'courierbi',),'Symbol'=>array(self::FONT_PLAIN=>'symbol',),'ZapfDingbats'=>array(self::FONT_PLAIN=>'zapfdingbats',),)
Array with fonts, and their equivalents for bold and italic markup. This array will be extended when loading new fonts, but contains the builtin fonts by default.
The fourth value for each font is bold + oblique, the index is the bitwise and combination of the repective combinations. Each font MUST have at least a value for FONT_PLAIN assigned. |
|
protected array |
$pages
Page instances, given as an array, indexed by their page number starting with 0. |
Method Summary
|
public void |
__construct(
)
Construct driver |
|
public float |
calculateWordWidth(
$word )
Calculate the rendered width of the current word |
|
public void |
createPage(
$width, $height )
Create a new page |
|
public void |
drawImage(
$file, $type, $x, $y, $width, $height )
Draw image |
|
public void |
drawWord(
$x, $y, $word )
Draw word at given position |
|
public float |
getCurrentLineHeight(
)
Get current line height |
|
public string |
save(
)
Generate and return PDF |
|
public void |
setTextFormatting(
$type, $value )
Set text formatting option |
|
public void |
trySetFont(
$name, $style )
Try to set font |
Inherited Methods
From
ezcDocumentPdfDriver :
Methods
__construct
void __construct(
)
Construct driver
Creates a new document instance maintaining all document context.
calculateWordWidth
float calculateWordWidth(
string
$word )
Calculate the rendered width of the current word
Calculate the width of the passed word, using the currently set text formatting options.
Parameters
| Name |
Type |
Description |
$word |
string |
|
Redefinition of
createPage
void createPage(
float
$width, float
$height )
Create a new page
Create a new page in the PDF document with the given width and height.
Parameters
| Name |
Type |
Description |
$width |
float |
|
$height |
float |
|
Redefinition of
drawImage
void drawImage(
string
$file, string
$type, float
$x, float
$y, float
$width, float
$height )
Draw image
Draw image at the defined position. The first parameter is the (absolute) path to the image file, and the second defines the type of the image. If the driver cannot handle this aprticular image type, it should throw an exception.
The further parameters define the location where the image should be rendered and the dimensions of the image in the rendered output. The dimensions do not neccesarily match the real image dimensions, and might require some kind of scaling inside the driver depending on the used backend.
Parameters
| Name |
Type |
Description |
$file |
string |
|
$type |
string |
|
$x |
float |
|
$y |
float |
|
$width |
float |
|
$height |
float |
|
Redefinition of
drawWord
void drawWord(
float
$x, float
$y, string
$word )
Draw word at given position
Draw the given word at the given position using the currently set text formatting options.
The coordinate specifies the left bottom edge of the words bounding box.
Parameters
| Name |
Type |
Description |
$x |
float |
|
$y |
float |
|
$word |
string |
|
Redefinition of
getCurrentLineHeight
float getCurrentLineHeight(
)
Get current line height
Return the current line height in millimeter based on the current font and text rendering settings.
Redefinition of
save
string save(
)
Generate and return PDF
Return the generated binary PDF content as a string.
Redefinition of
setTextFormatting
void setTextFormatting(
string
$type, mixed
$value )
Set text formatting option
Set a text formatting option. The names of the options are the same used in the PCSS files and need to be translated by the driver to the proper backend calls.
Parameters
| Name |
Type |
Description |
$type |
string |
|
$value |
mixed |
|
Redefinition of
trySetFont
void trySetFont(
string
$name, int
$style )
Try to set font
Stays with the old font, if the newly specified font is not available.
If the font does not support the given style, it falls back to the style used beforehand, and if this is also not support the plain style will be used.
Parameters
| Name |
Type |
Description |
$name |
string |
|
$style |
int |
|
Last updated: Mon, 29 Jun 2009