Overview

Packages

  • Pdf

Classes

  • Horde_Pdf_Exception
  • Horde_Pdf_Font_Courier
  • Horde_Pdf_Font_Courierb
  • Horde_Pdf_Font_Courierbi
  • Horde_Pdf_Font_Courieri
  • Horde_Pdf_Font_Helvetica
  • Horde_Pdf_Font_Helveticab
  • Horde_Pdf_Font_Helveticabi
  • Horde_Pdf_Font_Helveticai
  • Horde_Pdf_Font_Symbol
  • Horde_Pdf_Font_Times
  • Horde_Pdf_Font_Timesb
  • Horde_Pdf_Font_Timesbi
  • Horde_Pdf_Font_Timesi
  • Horde_Pdf_Font_Zapfdingbats
  • Horde_Pdf_Writer
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Pdf_Writer

The Horde_Pdf_Writer class provides a PHP-only implementation of a PDF library. No external libs or PHP extensions are required.

Package: Pdf
Category: Horde
Located at Horde/Pdf/Writer.php
Methods summary
public
# __construct( array $params = array() )

Constructor

Constructor

It allows to set up the page format, the orientation and the units of measurement used in all the methods (except for the font sizes).

Example:

$pdf = new Horde_Pdf_Writer(array('orientation' => 'P',
                                  'unit'   => 'mm',
                                  'format' => 'A4'));

Parameters

$params
<p>A hash with parameters for the created PDF object. Possible parameters are: - orientation - Default page orientation. Possible values are (case insensitive): - P or Portrait (default) - L or Landscape - unit - User measure units. Possible values 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. - format - The format used for pages. It can be either one of the following values (case insensitive): - A3 - A4 (default) - A5 - Letter - Legal or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by the unit parameter).</p>
public
# setMargins( float $left, float $top, float $right = null )

Defines the left, top and right margins.

Defines the left, top and right margins.

By default, they equal 1 cm. Call this method to change them.

Parameters

$left
Left margin.
$top
Top margin.
$right
<p>Right margin. If not specified default to the value of the left one.</p>

See

Horde_Pdf_Writer::setAutoPageBreak()
Horde_Pdf_Writer::setLeftMargin()
Horde_Pdf_Writer::setRightMargin()
Horde_Pdf_Writer::setTopMargin()
public
# setLeftMargin( float $margin )

Defines the left margin.

Defines the left margin.

The method can be called before creating the first page. If the current abscissa gets out of page, it is brought back to the margin.

Parameters

$margin
The margin.

See

Horde_Pdf_Writer::setAutoPageBreak()
Horde_Pdf_Writer::setMargins()
Horde_Pdf_Writer::setRightMargin()
Horde_Pdf_Writer::setTopMargin()
public
# setTopMargin( float $margin )

Defines the top margin.

Defines the top margin.

The method can be called before creating the first page.

Parameters

$margin
The margin.
public
# setRightMargin( float $margin )

Defines the right margin.

Defines the right margin.

The method can be called before creating the first page.

Parameters

$margin
The margin.
public float
# getPageWidth( )

Returns the actual page width.

Returns the actual page width.

Returns

float
The page width.
public float
# getPageHeight( )

Returns the actual page height.

Returns the actual page height.

Returns

float
The page height.
public
# setAutoPageBreak( boolean $auto, float $margin = 0 )

Enables or disables the automatic page breaking mode.

Enables or disables the automatic page breaking mode.

When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.

Parameters

$auto
Boolean indicating if mode should be on or off.
$margin
Distance from the bottom of the page.
public
# setDisplayMode( mixed $zoom, string $layout = 'continuous' )

Defines the way the document is to be displayed by the viewer.

Defines the way the document is to be displayed by the viewer.

The zoom level can be set: pages can be displayed entirely on screen, occupy the full width of the window, use real size, be scaled by a specific zooming factor or use viewer default (configured in the Preferences menu of Acrobat). The page layout can be specified too: single at once, continuous display, two columns or viewer default. By default, documents use the full width mode with continuous display.

Parameters

$zoom
<p>The zoom to use. It can be one of the following string values: - fullpage: entire page on screen - fullwidth: maximum width of window - real: uses real size (100% zoom) - default: uses viewer default mode or a number indicating the zooming factor.</p>
$layout
<p>The page layout. Possible values are: - single: one page at once - continuous: pages in continuously - two: two pages on two columns - default: uses viewer default mode Default value is continuous.</p>
public
# setCompression( boolean $compress )

Activates or deactivates page compression.

Activates or deactivates page compression.

When activated, the internal representation of each page is compressed, which leads to a compression ratio of about 2 for the resulting document. Compression is on by default.

Note: the zlib extension is required for this feature. If not present, compression will be turned off.

Parameters

$compress
<p>Boolean indicating if compression must be enabled or not.</p>
public
# setInfo( array|string $info, string $value = '' )

Set the info to a document.

Set the info to a document.

Possible info settings are: - title - subject - author - keywords - creator

Parameters

$info
<p>If passed as an array then the complete hash containing the info to be inserted into the document. Otherwise the name of setting to be set.</p>
$value
The value of the setting.
public
# aliasNbPages( string $alias = '{nb}' )

Defines an alias for the total number of pages.

Defines an alias for the total number of pages.

It will be substituted as the document is closed.

Example:

class My_Pdf extends Horde_Pdf_Writer {
    function footer()
    {
        // Go to 1.5 cm from bottom
        $this->setY(-15);
        // Select Arial italic 8
        $this->setFont('Arial', 'I', 8);
        // Print current and total page numbers
        $this->cell(0, 10, 'Page ' . $this->getPageNo() . '/{nb}', 0,
                    0, 'C');
    }
}
$pdf = new My_Pdf();
$pdf->aliasNbPages();

Parameters

$alias
The alias.

See

Horde_Pdf_Writer::getPageNo()
Horde_Pdf_Writer::footer()
public
# open( )

This method begins the generation of the PDF document; it must be called before any output commands.

This method begins the generation of the PDF document; it must be called before any output commands.

No page is created by this method, therefore it is necessary to call Horde_Pdf_Writer::addPage().

See

Horde_Pdf_Writer::addPage()
Horde_Pdf_Writer::close()
public
# close( )

Terminates the PDF document.

Terminates the PDF document.

If the document contains no page, Horde_Pdf_Writer::addPage() is called to prevent from getting an invalid document.

See

Horde_Pdf_Writer::open()
public
# addPage( string $orientation = '' )

Adds a new page to the document.

Adds a new page to the document.

If a page is already present, the Horde_Pdf_Writer::footer() method is called first to output the footer. Then the page is added, the current position set to the top-left corner according to the left and top margins, and Horde_Pdf_Writer::header() is called to display the header.

The font which was set before calling is automatically restored. There is no need to call Horde_Pdf_Writer::setFont() again if you want to continue with the same font. The same is true for colors and line width. The origin of the coordinate system is at the top-left corner and increasing ordinates go downwards.

Parameters

$orientation
<p>Page orientation. Possible values are (case insensitive): - P or Portrait - L or Landscape The default value is the one passed to the constructor.</p>

See

Horde_Pdf_Writer::header()
Horde_Pdf_Writer::footer()
Horde_Pdf_Writer::setMargins()
public
# header( )

This method is used to render the page header.

This method is used to render the page header.

It is automatically called by Horde_Pdf_Writer::addPage() and should not be called directly by the application. The implementation in Horde_Pdf_Writer is empty, so you have to subclass it and override the method if you want a specific processing.

Example:

class My_Pdf extends Horde_Pdf_Writer {
    function header()
    {
        // Select Arial bold 15
        $this->setFont('Arial', 'B', 15);
        // Move to the right
        $this->cell(80);
        // Framed title
        $this->cell(30, 10, 'Title', 1, 0, 'C');
        // Line break
        $this->newLine(20);
    }
}

See

Horde_Pdf_Writer::footer()
public
# footer( )

This method is used to render the page footer.

This method is used to render the page footer.

It is automatically called by Horde_Pdf_Writer::addPage() and Horde_Pdf_Writer::close() and should not be called directly by the application. The implementation in Horde_Pdf_Writer is empty, so you have to subclass it and override the method if you want a specific processing.

Example:

class My_Pdf extends Horde_Pdf_Writer {
   function footer()
   {
       // Go to 1.5 cm from bottom
       $this->setY(-15);
       // Select Arial italic 8
       $this->setFont('Arial', 'I', 8);
       // Print centered page number
       $this->cell(0, 10, 'Page ' . $this->getPageNo(), 0, 0, 'C');
   }
}

See

Horde_Pdf_Writer::header()
public integer
# getPageNo( )

Returns the current page number.

Returns the current page number.

Returns

integer

See

Horde_Pdf_Writer::aliasNbPages()
public
# setFillColor( string $cs, float $c1, float $c2 = 0, float $c3 = 0, float $c4 = 0 )

Sets the fill color.

Sets the fill color.

Depending on the colorspace called, the number of color component parameters required can be either 1, 3 or 4. The method can be called before the first page is created and the color is retained from page to page.

Parameters

$cs
<p>Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk', or 'gray'. Defaults to 'rgb'.</p>
$c1
<p>First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk.</p>
$c2
<p>Second color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c3
<p>Third color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c4
<p>Fourth color component, floating point value between 0 and 1. Required for cmyk.</p>

See

Horde_Pdf_Writer::setTextColor()
Horde_Pdf_Writer::setDrawColor()
Horde_Pdf_Writer::rect()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
public string
# getFillColor( )

Get the fill color

Get the fill color

Returns

string
public
# setTextColor( string $cs, float $c1, float $c2 = 0, float $c3 = 0, float $c4 = 0 )

Sets the text color.

Sets the text color.

Depending on the colorspace called, the number of color component parameters required can be either 1, 3 or 4. The method can be called before the first page is created and the color is retained from page to page.

Parameters

$cs
<p>Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk' or 'gray'. Defaults to 'rgb'.</p>
$c1
<p>First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk.</p>
$c2
<p>Second color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c3
<p>Third color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c4
<p>Fourth color component, floating point value between 0 and 1. Required for cmyk.</p>

See

Horde_Pdf_Writer::setFillColor()
Horde_Pdf_Writer::setDrawColor()
Horde_Pdf_Writer::rect()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
public string
# getTextColor( )

Get the text color

Get the text color

Returns

string
public
# setDrawColor( string $cs, float $c1, float $c2 = 0, float $c3 = 0, float $c4 = 0 )

Sets the draw color, used when drawing lines.

Sets the draw color, used when drawing lines.

Depending on the colorspace called, the number of color component parameters required can be either 1, 3 or 4. The method can be called before the first page is created and the color is retained from page to page.

Parameters

$cs
<p>Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk' or 'gray'. Defaults to 'rgb'.</p>
$c1
<p>First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk.</p>
$c2
<p>Second color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c3
<p>Third color component, floating point value between 0 and 1. Required for rgb and cmyk.</p>
$c4
<p>Fourth color component, floating point value between 0 and 1. Required for cmyk.</p>

See

Horde_Pdf_Writer::setFillColor()
Horde_Pdf_Writer::line()
Horde_Pdf_Writer::rect()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
public string
# getDrawColor( )

Get the draw color

Get the draw color

Returns

string
public float
# getStringWidth( string $text, boolean $pt = false )

Returns the length of a text string. A font must be selected.

Returns the length of a text string. A font must be selected.

Parameters

$text
The text whose length is to be computed.
$pt
<p>Whether the width should be returned in points or user units.</p>

Returns

float
public
# setLineWidth( float $width )

Defines the line width.

Defines the line width.

By default, the value equals 0.2 mm. The method can be called before the first page is created and the value is retained from page to page.

Parameters

$width
The width.

See

Horde_Pdf_Writer::line()
Horde_Pdf_Writer::rect()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
public string
# getDefaultOrientation( )

P (portrait) or L (landscape)

P (portrait) or L (landscape)

Returns

string
public integer
# getScale( )

Returns

integer
public float
# getFormatHeight( )

Returns

float
public float
# getFormatWidth( )

Returns

float
public
# line( float $x1, float $y1, float $x2, float $y2 )

Draws a line between two points.

Draws a line between two points.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x1
Abscissa of first point.
$y1
Ordinate of first point.
$x2
Abscissa of second point.
$y2
Ordinate of second point.

See

Horde_Pdf_Writer::setLineWidth()
Horde_Pdf_Writer::setDrawColor()
public
# rect( float $x, float $y, float $width, float $height, float $style = '' )

Outputs a rectangle.

Outputs a rectangle.

It can be drawn (border only), filled (with no border) or both.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x
Abscissa of upper-left corner.
$y
Ordinate of upper-left corner.
$width
Width.
$height
Height.
$style
<p>Style of rendering. Possible values are: - D or empty string: draw (default) - F: fill - DF or FD: draw and fill</p>

See

Horde_Pdf_Writer::setLineWidth()
Horde_Pdf_Writer::setDrawColor()
Horde_Pdf_Writer::setFillColor()
public
# circle( float $x, float $y, float $r, string $style = '' )

Outputs a circle. It can be drawn (border only), filled (with no border) or both.

Outputs a circle. It can be drawn (border only), filled (with no border) or both.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x
Abscissa of the center of the circle.
$y
Ordinate of the center of the circle.
$r
Circle radius.
$style
<p>Style of rendering. Possible values are: - D or empty string: draw (default) - F: fill - DF or FD: draw and fill</p>
public
# addFont( string $family, string $style = '', string $file = '' )

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 location of the definition file (and the font file itself when embedding) must be found at the full path name included.

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 location of the definition file (and the font file itself when embedding) must be found at the full path name included.

Example:

$pdf->addFont('Comic', 'I');
is equivalent to:
$pdf->addFont('Comic', 'I', 'comici.php');

Parameters

$family
<p>Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.</p>
$style
<p>Font style. Possible values are (case insensitive): - empty string: regular (default) - B: bold - I: italic - BI or IB: bold italic</p>
$file
<p>The font definition file. By default, the name is built from the family and style, in lower case with no space.</p>

See

Horde_Pdf_Writer::setFont()
public
# setFont( string $family, string $style = '', integer $size = null, boolean $force = false )

Sets the font used to print character strings.

Sets the font used to print character strings.

It is mandatory to call this method at least once before printing text or the resulting document would not be valid. The font can be either a standard one or a font added via the Horde_Pdf_Writer::addFont() method. Standard fonts use Windows encoding cp1252 (Western Europe).

The method can be called before the first page is created and the font is retained from page to page.

If you just wish to change the current font size, it is simpler to call Horde_Pdf_Writer::setFontSize().

Parameters

$family
<p>Family font. It can be either a name defined by <code><a href="class-Horde_Pdf_Writer.html#_addFont">Horde_Pdf_Writer::addFont()</a></code> or one of the standard families (case insensitive): - Courier (fixed-width) - Helvetica or Arial (sans serif) - Times (serif) - Symbol (symbolic) - ZapfDingbats (symbolic) It is also possible to pass an empty string. In that case, the current family is retained.</p>
$style
<p>Font style. Possible values are (case insensitive): - empty string: regular - B: bold - I: italic - U: underline or any combination. Bold and italic styles do not apply to Symbol and ZapfDingbats.</p>
$size
<p>Font size in points. The default value is the current size. If no size has been specified since the beginning of the document, the value taken is 12.</p>
$force
<p>Force the setting of the font. Each new page will require a new call to <code><a href="class-Horde_Pdf_Writer.html#_setFont">Horde_Pdf_Writer::setFont()</a></code> and setting this to true will make sure that the checks for same font calls will be skipped.</p>

See

Horde_Pdf_Writer::addFont()
Horde_Pdf_Writer::setFontSize()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
Horde_Pdf_Writer::write()
public
# setFontSize( float $size )

Defines the size of the current font.

Defines the size of the current font.

Parameters

$size
The size (in points).

See

Horde_Pdf_Writer::setFont()
public
# setFontStyle( string $style )

Defines the style of the current font.

Defines the style of the current font.

Parameters

$style
The font style.

See

Horde_Pdf_Writer::setFont()
public
# addLink( )

Creates a new internal link and returns its identifier.

Creates a new internal link and returns its identifier.

An internal link is a clickable area which directs to another place within the document.

The identifier can then be passed to Horde_Pdf_Writer::cell(), {@link()} write, Horde_Pdf_Writer::image() or Horde_Pdf_Writer::link(). The destination is defined with Horde_Pdf_Writer::setLink().

See

Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::write()
Horde_Pdf_Writer::image()
Horde_Pdf_Writer::link()
Horde_Pdf_Writer::setLink()
public
# setLink( integer $link, float $y = 0, integer $page = -1 )

Defines the page and position a link points to.

Defines the page and position a link points to.

Parameters

$link
The link identifier returned by <code><a href="class-Horde_Pdf_Writer.html#_addLink">Horde_Pdf_Writer::addLink()</a></code>.
$y
<p>Ordinate of target position; -1 indicates the current position. The default value is 0 (top of page).</p>
$page
<p>Number of target page; -1 indicates the current page.</p>

See

Horde_Pdf_Writer::addLink()
public
# link( float $x, float $y, float $width, float $height, mixed $link )

Puts a link on a rectangular area of the page.

Puts a link on a rectangular area of the page.

Text or image links are generally put via Horde_Pdf_Writer::cell(), Horde_Pdf_Writer::write() or Horde_Pdf_Writer::image(), but this method can be useful for instance to define a clickable area inside an image.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x
<p>Abscissa of the upper-left corner of the rectangle.</p>
$y
<p>Ordinate of the upper-left corner of the rectangle.</p>
$width
Width of the rectangle.
$height
Height of the rectangle.
$link
URL or identifier returned by <code><a href="class-Horde_Pdf_Writer.html#_addLink">Horde_Pdf_Writer::addLink()</a></code>.

See

Horde_Pdf_Writer::addLink()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::write()
Horde_Pdf_Writer::image()
public
# text( float $x, float $y, string $text )

Prints a character string.

Prints a character string.

The origin is on the left of the first character, on the baseline. This method allows to place a string precisely on the page, but it is usually easier to use Horde_Pdf_Writer::cell(), Horde_Pdf_Writer::multiCell() or Horde_Pdf_Writer::write() which are the standard methods to print text.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x
Abscissa of the origin.
$y
Ordinate of the origin.
$text
String to print.

See

Horde_Pdf_Writer::setFont()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::multiCell()
Horde_Pdf_Writer::write()
public boolean
# acceptPageBreak( )

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 Horde_Pdf_Writer::setAutoPageBreak(). This method is called automatically and should not be called directly by the application.

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 Horde_Pdf_Writer::setAutoPageBreak(). This method is called automatically and should not be called directly by the application.

Returns

boolean

See

Horde_Pdf_Writer::setAutoPageBreak()
public
# cell( float $width, float $height = 0, string $text = '', mixed $border = 0, integer $ln = 0, string $align = '', integer $fill = 0, string $link = '' )

Prints a cell (rectangular area) with optional borders, background color and character string.

Prints a cell (rectangular area) with optional borders, background color and character string.

The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.

Parameters

$width
<p>Cell width. If 0, the cell extends up to the right margin.</p>
$height
Cell height.
$text
String to print.
$border
<p>Indicates if borders must be drawn around the cell. The value can be either a number: - 0: no border (default) - 1: frame or a string containing some or all of the following characters (in any order): - L: left - T: top - R: right - B: bottom</p>
$ln
<p>Indicates where the current position should go after the call. Possible values are: - 0: to the right (default) - 1: to the beginning of the next line - 2: below Putting 1 is equivalent to putting 0 and calling <code><a href="class-Horde_Pdf_Writer.html#_newLine">Horde_Pdf_Writer::newLine()</a></code> just after.</p>
$align
<p>Allows to center or align the text. Possible values are: - L or empty string: left (default) - C: center - R: right</p>
$fill
<p>Indicates if the cell fill type. Possible values are: - 0: transparent (default) - 1: painted</p>
$link
URL or identifier returned by <code><a href="class-Horde_Pdf_Writer.html#_addLink">Horde_Pdf_Writer::addLink()</a></code>.

See

Horde_Pdf_Writer::setFont()
Horde_Pdf_Writer::setDrawColor()
Horde_Pdf_Writer::setFillColor()
Horde_Pdf_Writer::setLineWidth()
Horde_Pdf_Writer::addLink()
Horde_Pdf_Writer::newLine()
Horde_Pdf_Writer::multiCell()
Horde_Pdf_Writer::write()
Horde_Pdf_Writer::setAutoPageBreak()
public
# multiCell( float $width, float $height, string $text, mixed $border = 0, string $align = 'J', integer $fill = 0 )

This method allows printing text with line breaks.

This method allows printing text with line breaks.

They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other. Text can be aligned, centered or justified. The cell block can be framed and the background painted.

Parameters

$width
<p>Width of cells. If 0, they extend up to the right margin of the page.</p>
$height
Height of cells.
$text
String to print.
$border
<p>Indicates if borders must be drawn around the cell block. The value can be either a number: - 0: no border (default) - 1: frame or a string containing some or all of the following characters (in any order): - L: left - T: top - R: right - B: bottom</p>
$align
<p>Sets the text alignment. Possible values are: - L: left alignment - C: center - R: right alignment - J: justification (default value)</p>
$fill
<p>Indicates if the cell background must: - 0: transparent (default) - 1: painted</p>

See

Horde_Pdf_Writer::setFont()
Horde_Pdf_Writer::setDrawColor()
Horde_Pdf_Writer::setFillColor()
Horde_Pdf_Writer::setLineWidth()
Horde_Pdf_Writer::cell()
Horde_Pdf_Writer::write()
Horde_Pdf_Writer::setAutoPageBreak()
public
# write( float $height, string $text, mixed $link = '' )

This method prints text from the current position.

This method prints text from the current position.

When the right margin is reached (or the \n character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text.

It is possible to put a link on the text.

Example:

// Begin with regular font
$pdf->setFont('Arial', '', 14);
$pdf->write(5, 'Visit ');
// Then put a blue underlined link
$pdf->setTextColor(0, 0, 255);
$pdf->setFont('', 'U');
$pdf->write(5, 'www.fpdf.org', 'http://www.fpdf.org');

Parameters

$height
Line height.
$text
String to print.
$link
URL or identifier returned by <code><a href="class-Horde_Pdf_Writer.html#_addLink">Horde_Pdf_Writer::addLink()</a></code>.

See

Horde_Pdf_Writer::setFont()
Horde_Pdf_Writer::addLink()
Horde_Pdf_Writer::multiCell()
Horde_Pdf_Writer::setAutoPageBreak()
public
# writeRotated( integer $x, integer $y, string $text, float $text_angle, float $font_angle = 0 )

Writes text at an angle.

Writes text at an angle.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

Parameters

$x
X coordinate.
$y
Y coordinate.
$text
Text to write.
$text_angle
Angle to rotate (Eg. 90 = bottom to top).
$font_angle
Rotate characters as well as text.

See

Horde_Pdf_Writer::setFont()
public
# image( string $file, float $x, float $y, float $width = 0, float $height = 0, string $type = '', mixed $link = '' )

Prints an image in the page.

Prints an image in the page.

The upper-left corner and at least one of the dimensions must be specified; the height or the width can be calculated automatically in order to keep the image proportions. Supported formats are JPEG and PNG.

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).

For JPEG, all flavors are allowed: - gray scales - true colors (24 bits) - CMYK (32 bits)

For PNG, are allowed: - gray scales on at most 8 bits (256 levels) - indexed colors - true colors (24 bits) but are not supported: - Interlacing - Alpha channel

If a transparent color is defined, it will be taken into account (but will be only interpreted by Acrobat 4 and above). The format can be specified explicitly or inferred from the file extension. It is possible to put a link on the image.

Remark: if an image is used several times, only one copy will be embedded in the file.

Parameters

$file
Name of the file containing the image.
$x
Abscissa of the upper-left corner.
$y
Ordinate of the upper-left corner.
$width
<p>Width of the image in the page. If equal to zero, it is automatically calculated to keep the original proportions.</p>
$height
<p>Height of the image in the page. If not specified or equal to zero, it is automatically calculated to keep the original proportions.</p>
$type
<p>Image format. Possible values are (case insensitive): JPG, JPEG, PNG. If not specified, the type is inferred from the file extension.</p>
$link
URL or identifier returned by <code><a href="class-Horde_Pdf_Writer.html#_addLink">Horde_Pdf_Writer::addLink()</a></code>.

See

Horde_Pdf_Writer::addLink()
public
# newLine( float $height = '' )

Performs a line break.

Performs a line break.

The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter.

Parameters

$height
<p>The height of the break. By default, the value equals the height of the last printed cell.</p>

See

Horde_Pdf_Writer::cell()
public integer
# getPage( )

Get the current page

Get the current page

Returns

integer
public
# setPage( integer $page )

Set the current page

Set the current page

Parameters

$page
public float
# getX( )

Returns the abscissa of the current position in user units.

Returns the abscissa of the current position in user units.

Returns

float

See

Horde_Pdf_Writer::setX()
Horde_Pdf_Writer::getY()
Horde_Pdf_Writer::setY()
public
# setX( float $x )

Defines the abscissa of the current position.

Defines the abscissa of the current position.

If the passed value is negative, it is relative to the right of the page.

Parameters

$x
The value of the abscissa.

See

Horde_Pdf_Writer::getX()
Horde_Pdf_Writer::getY()
Horde_Pdf_Writer::setY()
Horde_Pdf_Writer::setXY()
public float
# getY( )

Returns the ordinate of the current position in user units.

Returns the ordinate of the current position in user units.

Returns

float

See

Horde_Pdf_Writer::setY()
Horde_Pdf_Writer::getX()
Horde_Pdf_Writer::setX()
public
# setY( float $y )

Defines the ordinate of the current position.

Defines the ordinate of the current position.

If the passed value is negative, it is relative to the bottom of the page.

Parameters

$y
The value of the ordinate.

See

Horde_Pdf_Writer::getX()
Horde_Pdf_Writer::getY()
Horde_Pdf_Writer::setY()
Horde_Pdf_Writer::setXY()
public
# setXY( float $x, float $y )

Defines the abscissa and ordinate of the current position.

Defines the abscissa and ordinate of the current position.

If the passed values are negative, they are relative respectively to the right and bottom of the page.

Parameters

$x
The value of the abscissa.
$y
The value of the ordinate.

See

Horde_Pdf_Writer::setX()
Horde_Pdf_Writer::setY()
public
# flush( )

Returns the current buffer content and resets the buffer.

Returns the current buffer content and resets the buffer.

Use this method when creating large files to avoid memory problems. This method doesn't work in combination with the save() method, use getOutput() at the end. Calling this method doubles the memory usage during the call.

See

Horde_Pdf_Writer::getOutput()
public
# getOutput( )

Returns the raw Pdf file.

Returns the raw Pdf file.

See

Horde_Pdf_Writer::flush()
public
# save( string $filename = 'unknown.pdf' )

Saves the PDF file on the filesystem.

Saves the PDF file on the filesystem.

Parameters

$filename
The filename for the output file.
Properties summary
public float $fwPt

Current width of page format in points.

Current width of page format in points.

#
public float $fhPt

Current height of page format in points.

Current height of page format in points.

#
public float $fw

Current width of page format in user units.

Current width of page format in user units.

#
public float $fh

Current height of page format in user units.

Current height of page format in user units.

#
public float $wPt

Current width of page in points.

Current width of page in points.

#
public float $hPt

Current height of page in points.

Current height of page in points.

#
public float $w

Current width of page in user units

Current width of page in user units

#
public float $h

Current height of page in user units

Current height of page in user units

#
public float $x

The current horizontal position for cell positioning. Value is set in user units and is calculated from the top left corner as origin.

The current horizontal position for cell positioning. Value is set in user units and is calculated from the top left corner as origin.

#
public float $y

The current vertical position for cell positioning. Value is set in user units and is calculated from the top left corner as origin.

The current vertical position for cell positioning. Value is set in user units and is calculated from the top left corner as origin.

#
API documentation generated by ApiGen