Zeta Components Manual :: Docs For Class ezcDocumentPdfDriver
Document::ezcDocumentPdfDriver
Class ezcDocumentPdfDriver
Abstract base class for driver implementations.
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.
Source for this file: /Document/src/document/pdf/driver.php
Version: | //autogen// |
Descendants
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 |
Member Variables
protected ezcDocumentPdfOptions |
$options
PDF options |
Method Summary
public void |
__construct(
)
Construct driver |
public void |
addExternalLink(
$x
, $y
, $width
, $height
, $url
)
Add an external link |
public void |
addInternalLink(
$x
, $y
, $width
, $height
, $target
)
Add an internal link |
public void |
addInternalLinkTarget(
$id
)
Add an internal link target |
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 void |
drawPolygon(
$points
, $color
)
Draw a fileld polygon |
public void |
drawPolyline(
$points
, $color
, $width
, [ $close
= true] )
Draw a polyline |
public abstract void |
drawWord(
$x
, $y
, $word
)
Draw word at given position |
public abstract float |
getCurrentLineHeight(
)
Get current line height |
public void |
registerFont(
$name
, $type
, $pathes
)
Register a font |
public abstract string |
save(
)
Generate and return PDF |
public void |
setMetaData(
$key
, $value
)
Set metadata |
public void |
setOptions(
$options
, $compress
)
Set compression |
public abstract void |
setTextFormatting(
$type
, $value
)
Set text formatting option |
Methods
__construct
Construct driver
Creates a new PDF driver.
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::__construct() |
Construct driver |
ezcDocumentPdfHaruDriver::__construct() |
Construct driver |
addExternalLink
Add an external link
Add an external link to the rectangle specified by its top-left position, width and height. The last parameter is the actual URL to link to.
Parameters:
Name | Type | Description |
---|---|---|
$x |
float | |
$y |
float | |
$width |
float | |
$height |
float | |
$url |
string |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::addExternalLink() |
Add an external link |
ezcDocumentPdfHaruDriver::addExternalLink() |
Add an external link |
addInternalLink
Add an internal link
Add an internal link to the rectangle specified by its top-left position, width and height. The last parameter is the target identifier to link to.
Parameters:
Name | Type | Description |
---|---|---|
$x |
float | |
$y |
float | |
$width |
float | |
$height |
float | |
$target |
string |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::addInternalLink() |
Add an internal link |
ezcDocumentPdfHaruDriver::addInternalLink() |
Add an internal link |
addInternalLinkTarget
Add an internal link target
Add an internal link to the current page. The last parameter is the target identifier.
Parameters:
Name | Type | Description |
---|---|---|
$id |
string |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::addInternalLinkTarget() |
Add an internal link target |
ezcDocumentPdfHaruDriver::addInternalLinkTarget() |
Add an internal link target |
calculateWordWidth
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
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
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 |
drawPolygon
Draw a fileld polygon
Draw any filled polygon, filled using the defined color. The color should be passed as an array with the keys "red", "green", "blue" and optionally "alpha". Each key should have a value between 0 and 1 associated.
The polygon itself is specified as an array of two-tuples, specifying the x and y coordinate of the point.
Parameters:
Name | Type | Description |
---|---|---|
$points |
array | |
$color |
array |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::drawPolygon() |
Draw a fileld polygon |
ezcDocumentPdfHaruDriver::drawPolygon() |
Draw a fileld polygon |
drawPolyline
Draw a polyline
Draw any non-filled polygon, filled using the defined color. The color should be passed as an array with the keys "red", "green", "blue" and optionally "alpha". Each key should have a value between 0 and 1 associated.
The polyline itself is specified as an array of two-tuples, specifying the x and y coordinate of the point.
The thrid parameter defines the width of the border and the last parameter may optionally be set to false to not close the polygon (draw another line from the last point to the first one).
Parameters:
Name | Type | Description |
---|---|---|
$points |
array | |
$color |
array | |
$width |
float | |
$close |
bool |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::drawPolyline() |
Draw a polyline |
ezcDocumentPdfHaruDriver::drawPolyline() |
Draw a polyline |
drawWord
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
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 |
registerFont
Register a font
Registers a font, which can be used by its name later in the driver. The given type is either self::FONT_PLAIN or a bitwise combination of self::FONT_BOLD and self::FONT_OBLIQUE.
The third paramater specifies an array of pathes with references to font definition files. Multiple pathes may be specified to provide the same font using different types, because not all drivers may process all font types.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string | |
$type |
int | |
$pathes |
array |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::registerFont() |
Register a font |
ezcDocumentPdfHaruDriver::registerFont() |
Register a font |
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 |
setMetaData
Set metadata
Set document meta data. The meta data types are identified by a list of keys, common to PDF, like: title, author, subject, created, modified.
The values are passed like embedded in the docbook document and might need to be reformatted.
Parameters:
Name | Type | Description |
---|---|---|
$key |
string | |
$value |
string |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentPdfTcpdfDriver::setMetaData() |
Set metadata |
ezcDocumentPdfHaruDriver::setMetaData() |
Set metadata |
setOptions
Set compression
Set whether the generated PDF should be compressed or not.
Parameters:
Name | Type | Description |
---|---|---|
$compress |
bool | |
$options |
ezcDocumentPdfOptions |
setTextFormatting
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 |