[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/File/ -> PDF.php (sommaire)

(pas de description)

Poids: 2797 lignes (95 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

File_PDF:: (69 méthodes):
  factory()
  raiseError()
  setMargins()
  setLeftMargin()
  setTopMargin()
  setRightMargin()
  setAutoPageBreak()
  setDisplayMode()
  setCompression()
  setInfo()
  aliasNbPages()
  open()
  close()
  addPage()
  header()
  footer()
  getPageNo()
  setFillColor()
  setDrawColor()
  getStringWidth()
  setLineWidth()
  line()
  rect()
  circle()
  addFont()
  setFont()
  setFontSize()
  addLink()
  setLink()
  link()
  text()
  acceptPageBreak()
  cell()
  multiCell()
  write()
  writeRotated()
  image()
  newLine()
  getX()
  setX()
  getY()
  setY()
  setXY()
  getOutput()
  output()
  save()
  _toPt()
  _getFontFile()
  _link()
  _beginDoc()
  _putPages()
  _putFonts()
  _putImages()
  _putResources()
  _putInfo()
  _putCatalog()
  _putTrailer()
  _endDoc()
  _beginPage()
  _endPage()
  _newobj()
  _doUnderline()
  _parseJPG()
  _parsePNG()
  _freadInt()
  _textString()
  _escape()
  _putStream()
  _out()


Classe: File_PDF  - X-Ref

File_PDF::

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

Based on the FPDF class by Olivier Plathey (http://www.fpdf.org).

Copyright 2003-2006 Olivier Plathey <olivier@fpdf.org>
Copyright 2003-2006 Marko Djukic <marko@oblo.com>

See the enclosed file COPYING for license information (LGPL). If you did not
receive this file, see http://www.fsf.org/copyleft/lgpl.html.

$Horde: framework/File_PDF/PDF.php,v 1.18.10.12 2006/01/01 21:28:15 jan Exp $

factory($params = array()   X-Ref
Attempts to return a conrete PDF instance. 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:<pre>
$pdf = &File_PDF::factory(array('orientation' => 'P',
'unit' => 'mm',
'format' => 'A4'));</pre>

param: array $params  A hash with parameters for the created PDF object.
param: string $class  The concrete class name to return an instance of.

raiseError($error)   X-Ref
Returns a PEAR_Error object. Wraps around PEAR::raiseError() to
avoid having to include PEAR.php unless an error occurs.

param: mixed $error  The error message.
return: object PEAR_Error

setMargins($left, $top, $right = null)   X-Ref
Defines the left, top and right margins. By default, they equal
1 cm.  Call this method to change them.

param: float $left   Left margin.
param: float $top    Top margin.
param: float $right  Right margin. If not specified default to the value

setLeftMargin($margin)   X-Ref
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.

param: float $margin   The margin.

setTopMargin($margin)   X-Ref
Defines the top margin. The method can be called before creating the
first page.

param: float $margin  The margin.

setRightMargin($margin)   X-Ref
Defines the right margin. The method can be called before creating the
first page.

param: float $margin  The margin.

setAutoPageBreak($auto, $margin = 0)   X-Ref
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.

param: boolean auto   Boolean indicating if mode should be on or off.
param: float $margin  Distance from the bottom of the page.

setDisplayMode($zoom, $layout = 'continuous')   X-Ref
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.

param: mixed $zoom             The zoom to use. It can be one of the
param: string layout  The page layout. Possible values are:

setCompression($compress)   X-Ref
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.

param: boolean $compress  Boolean indicating if compression must be

setInfo($info, $value = '')   X-Ref
Set the info to a document. Possible info settings are:
- title
- subject
- author
- keywords
- creator

param: mixed $info    If passed as an array then the complete hash
param: string $value  The value of the setting.

aliasNbPages($alias = '{nb}')   X-Ref
Defines an alias for the total number of pages. It will be substituted
as the document is closed.

Example:
class My_File_PDF extends File_PDF {
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 = &My_File_PDF::factory();
$pdf->aliasNbPages();

param: string $alias  The alias. Default value: {nb}.

open()   X-Ref
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 File_PDF::addPage.


close()   X-Ref
Terminates the PDF document. It is not necessary to call this method
explicitly because File_PDF::output does it automatically.
If the document contains no page, File_PDF::addPage is called to prevent
from getting an invalid document.


addPage($orientation = '')   X-Ref
Adds a new page to the document. If a page is already present, the
File_PDF::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 File_PDF::header is called to display
the header.
The font which was set before calling is automatically restored. There
is no need to call File_PDF::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.

param: string $orientation  Page orientation. Possible values

header()   X-Ref
This method is used to render the page header. It is automatically
called by File_PDF::addPage and should not be called directly by the
application. The implementation in File_PDF:: is empty, so you have to
subclass it and override the method if you want a specific processing.

Example:

class My_File_PDF extends File_PDF {
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);
}
}


footer()   X-Ref
This method is used to render the page footer. It is automatically
called by File_PDF::addPage and File_PDF::close and should not be called
directly by the application. The implementation in File_PDF:: is empty,
so you have to subclass it and override the method if you want a specific
processing.

Example:

class My_File_PDF extends File_PDF {
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');
}
}


getPageNo()   X-Ref
Returns the current page number.

return: integer

setFillColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)   X-Ref
Sets the fill color. Specifies the color for both filled areas and
text. 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.

param: string $cs  Indicates the colorspace which can be either 'rgb',
param: float $c1   First color component, floating point value between 0
param: float $c2   Second color component, floating point value between
param: float $c3   Third color component, floating point value between
param: float $c4   Fourth color component, floating point value between

setDrawColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)   X-Ref
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.

param: string $cs  Indicates the colorspace which can be either 'rgb',
param: float $c1   First color component, floating point value between 0
param: float $c2   Second color component, floating point value between
param: float $c3   Third color component, floating point value between 0
param: float $c4   Fourth color component, floating point value between

getStringWidth($text, $pt = false)   X-Ref
Returns the length of a text string. A font must be selected.

param: string $text  The text whose length is to be computed.
param: boolean $pt   Boolean to indicate if the width should be returned
return: float

setLineWidth($width)   X-Ref
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.

param: float $width  The width.

line($x1, $y1, $x2, $y2)   X-Ref
Draws a line between two points.

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

rect($x, $y, $width, $height, $style = '')   X-Ref
Outputs a rectangle. It can be drawn (border only), filled (with no
border) or both.

param: float $x       Abscissa of upper-left corner.
param: float $y       Ordinate of upper-left corner.
param: float $width   Width.
param: float $height  Height.
param: float $style   Style of rendering. Possible values are:

circle($x, $y, $r, $style = '')   X-Ref
Outputs a circle. It can be drawn (border only), filled (with no
border) or both.

param: float $x       Abscissa of the center of the circle.
param: float $y       Ordinate of the center of the circle.
param: float $r       Circle radius.
param: string $style  Style of rendering. Possible values are:

addFont($family, $style = '', $file = '')   X-Ref
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');

param: string $family  Font family. The name can be chosen arbitrarily.
param: string $style   Font style. Possible values are (case
param: string $file    The font definition file. By default, the name is

setFont($family, $style = '', $size = null, $force = false)   X-Ref
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 File_PDF::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
File_PDF::setFontSize.

param: string $family  Family font. It can be either a name defined by
param: string $style   Font style. Possible values are (case
param: integer $size   Font size in points. The default value is the
param: boolean $force  Force the setting of the font. Each new page will

setFontSize($size)   X-Ref
Defines the size of the current font.

param: float $size  The size (in points).

addLink()   X-Ref
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 File_PDF::cell, File_PDF::write,
File_PDF::image or File_PDF::link. The destination is defined with
File_PDF::setLink.


setLink($link, $y = 0, $page = -1)   X-Ref
Defines the page and position a link points to.

param: integer $link  The link identifier returned by File_PDF::addLink.
param: float $y       Ordinate of target position; -1 indicates the
param: integer $page  Number of target page; -1 indicates the current

link($x, $y, $width, $height, $link)   X-Ref
Puts a link on a rectangular area of the page. Text or image links are
generally put via File_PDF::cell, File_PDF::Write or File_PDF::image,
but this method can be useful for instance to define a clickable area
inside an image.

param: float $x       Abscissa of the upper-left corner of the rectangle.
param: float $y       Ordinate of the upper-left corner of the rectangle.
param: float $width   Width of the rectangle.
param: float $height  Height of the rectangle.
param: mixed $link    URL or identifier returned by File_PDF::addLink.

text($x, $y, $text)   X-Ref
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 File_PDF::cell,
File_PDF::multiCell or File_PDF::Write which are the standard methods to
print text.

param: float $x      Abscissa of the origin.
param: float $y      Ordinate of the origin.
param: string $text  String to print.

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

return: boolean

cell($width, $height = 0, $text = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = '')   X-Ref
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.

param: float $width   Cell width. If 0, the cell extends up to the right
param: float $height  Cell height. Default value: 0.
param: string $text   String to print. Default value: empty.
param: mixed $border  Indicates if borders must be drawn around the
param: integer $ln    Indicates where the current position should go
param: string $align  Allows to center or align the text. Possible
param: integer $fill  Indicates if the cell fill type. Possible values
param: string $link   URL or identifier returned by

multiCell($width, $height, $text, $border = 0, $align = 'J', $fill = 0)   X-Ref
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.

param: float $width   Width of cells. If 0, they extend up to the right
param: float $height  Height of cells.
param: string $text   String to print.
param: mixed $border  Indicates if borders must be drawn around the cell
param: string $align  Sets the text alignment. Possible values are:
param: integer $fill  Indicates if the cell background must:

write($height, $text, $link = '')   X-Ref
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');

param: float $height  Line height.
param: string $text   String to print.
param: mixed $link    URL or identifier returned by AddLink().

writeRotated($x, $y, $text, $text_angle, $font_angle = 0)   X-Ref
write Rotated Text.

Write text at an angle.

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

image($file, $x, $y, $width = 0, $height = 0, $type = '', $link = '')   X-Ref
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.

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.

param: string $file   Name of the file containing the image.
param: float $x       Abscissa of the upper-left corner.
param: float $y       Ordinate of the upper-left corner.
param: float $width   Width of the image in the page. If equal to zero,
param: float $height  Height of the image in the page. If not specified
param: string $type   Image format. Possible values are (case
param: mixed $link    URL or identifier returned by File_PDF::addLink.

newLine($height = '')   X-Ref
Performs a line break. The current abscissa goes back to the left
margin and the ordinate increases by the amount passed in parameter.

param: float $height  The height of the break. By default, the value

getX()   X-Ref
Returns the abscissa of the current position in user units.

return: float

setX($x)   X-Ref
Defines the abscissa of the current position. If the passed value is
negative, it is relative to the right of the page.

param: float $x  The value of the abscissa.

getY()   X-Ref
Returns the ordinate of the current position in user units.

return: float

setY($y)   X-Ref
Defines the ordinate of the current position. If the passed value is
negative, it is relative to the bottom of the page.

param: float $y  The value of the ordinate.

setXY($x, $y)   X-Ref
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.

param: float $x  The value of the abscissa.
param: float $y  The value of the ordinate.

getOutput()   X-Ref
Returns the raw PDF file.


output($filename = 'unknown.pdf', $inline = false)   X-Ref
Function to output the buffered data to the browser.

param: string $filename  The filename for the output file.
param: boolean $inline   True if inline, false if attachment.

save($filename = 'unknown.pdf')   X-Ref
Function to save the PDF file somewhere local to the server.

param: string $filename  The filename for the output file.

_toPt($val)   X-Ref
Pas de description

_getFontFile($fontkey, $path = '')   X-Ref
Pas de description

_link($x, $y, $width, $height, $link)   X-Ref
Pas de description

_beginDoc()   X-Ref
Pas de description

_putPages()   X-Ref
Pas de description

_putFonts()   X-Ref
Pas de description

_putImages()   X-Ref
Pas de description

_putResources()   X-Ref
Pas de description

_putInfo()   X-Ref
Pas de description

_putCatalog()   X-Ref
Pas de description

_putTrailer()   X-Ref
Pas de description

_endDoc()   X-Ref
Pas de description

_beginPage($orientation)   X-Ref
Pas de description

_endPage()   X-Ref
Pas de description

_newobj()   X-Ref
Pas de description

_doUnderline($x, $y, $text)   X-Ref
Pas de description

_parseJPG($file)   X-Ref
Pas de description

_parsePNG($file)   X-Ref
Pas de description

_freadInt($f)   X-Ref
Pas de description

_textString($s)   X-Ref
Pas de description

_escape($s)   X-Ref
Pas de description

_putStream($s)   X-Ref
Pas de description

_out($s)   X-Ref
Pas de description



Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7