Path

ez components / documentation / api reference / 2009.1.2 / document


eZ Components 2009.1.2

Document: ezcDocumentPdfDriver

[ Tutorial ] [ Conversion ] [ Styles ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcDocumentPdfDriver

Abstract base class for driver implementations. [source]
Driver implement the actual creation of PDF documents. They offer a simple unified API for PDF creation and proxy them to the actual PDF implementation, which will create the binary data.
The unit used for all values passed to methods of this class is milimeters. The extending drivers need to transform these values in a representation they can use.

Descendents

Child Class Description
ezcDocumentPdfTcpdfDriver Pdf driver based on TCPDF
ezcDocumentPdfHaruDriver Pdf driver based on pecl/haru

Constants

FONT_BOLD = 1 Bold text
FONT_OBLIQUE = 2 Italic text
FONT_PLAIN = 0 Normal text
FONT_UNDERLINE = 4 Underlined text

Method Summary

public abstract float calculateWordWidth( $word )
Calculate the rendered width of the current word
public abstract void createPage( $width, $height )
Create a new page
public abstract void drawImage( $file, $type, $x, $y, $width, $height )
Draw image
public abstract void drawWord( $x, $y, $word )
Draw word at given position
public abstract float getCurrentLineHeight( )
Get current line height
public abstract string save( )
Generate and return PDF
public abstract void setTextFormatting( $type, $value )
Set text formatting option

Methods

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  

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::calculateWordWidth() Calculate the rendered width of the current word
ezcDocumentPdfHaruDriver::calculateWordWidth() Calculate the rendered width of the current word

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  

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::createPage() Create a new page
ezcDocumentPdfHaruDriver::createPage() Create a new page

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  

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::drawImage() Draw image
ezcDocumentPdfHaruDriver::drawImage() Draw image

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  

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::drawWord() Draw word at given position
ezcDocumentPdfHaruDriver::drawWord() Draw word at given position

getCurrentLineHeight

float getCurrentLineHeight( )
Get current line height
Return the current line height in millimeter based on the current font and text rendering settings.

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::getCurrentLineHeight() Get current line height
ezcDocumentPdfHaruDriver::getCurrentLineHeight() Get current line height

save

string save( )
Generate and return PDF
Return the generated binary PDF content as a string.

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::save() Generate and return PDF
ezcDocumentPdfHaruDriver::save() Generate and return PDF

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  

Redefined in descendants as

Method Description
ezcDocumentPdfTcpdfDriver::setTextFormatting() Set text formatting option
ezcDocumentPdfHaruDriver::setTextFormatting() Set text formatting option

Last updated: Tue, 01 Sep 2009