Class: File_PDF
Source Location: /File_PDF-0.3.3/PDF.php
Inherited Variables
|
Inherited Methods
|
Class Details
[line 39]
Class Variables
Method Detail
acceptPageBreak [line 1789]
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 setAutoPageBreak(). This method is called automatically and should not be called directly by the application.
addFont [line 1434]
void 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. Example: $pdf->addFont('Comic', 'I');
is equivalent to:
$pdf->addFont('Comic', 'I', 'comici.php');
Parameters:
addLink [line 1659]
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 cell(), {@link()} write, image() or link(). The destination is defined with setLink().
addPage [line 921]
void addPage(
[string
$orientation = ''])
|
|
Adds a new page to the document. If a page is already present, the 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 header() is called to display the header. The font which was set before calling is automatically restored. There is no need to call 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:
aliasNbPages [line 846]
void aliasNbPages(
[string
$alias = '{nb}'])
|
|
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();
Parameters:
cell [line 1846]
void 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. 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:
circle [line 1340]
void circle(
float
$x, float
$y, float
$r, [string
$style = ''])
|
|
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:
close [line 876]
Terminates the PDF document. It is not necessary to call this method explicitly because output() does it automatically. If the document contains no page, addPage() is called to prevent from getting an invalid document.
factory [line 497]
void &factory(
[array
$params = array()], [string
$class = 'File_PDF'])
|
|
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: $pdf = File_PDF::factory(array('orientation' => 'P',
'unit' => 'mm',
'format' => 'A4'));
Parameters:
flush [line 2509]
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 output() or save() methods, use getOutput() at the end. Calling this method doubles the memory usage during the call.
footer [line 1059]
This method is used to render the page footer. It is automatically called by addPage() and 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');
}
}
getOutput [line 2528]
Returns the raw PDF file.
getPageHeight [line 707]
Returns the actual page height.
getPageNo [line 1071]
Returns the current page number.
getPageWidth [line 694]
Returns the actual page width.
getStringWidth [line 1206]
float getStringWidth(
string
$text, [boolean
$pt = false])
|
|
Returns the length of a text string. A font must be selected.
Parameters:
getX [line 2412]
Returns the abscissa of the current position in user units.
getY [line 2450]
Returns the ordinate of the current position in user units.
header [line 1029]
This method is used to render the page header. It is automatically called by 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);
}
}
image [line 2319]
void image(
string
$file, float
$x, float
$y, [float
$width = 0], [float
$height = 0], [string
$type = ''], [mixed
$link = ''])
|
|
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: 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:
line [line 1260]
void line(
float
$x1, float
$y1, float
$x2, float
$y2)
|
|
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:
link [line 1712]
void link(
float
$x, float
$y, float
$width, float
$height, mixed
$link)
|
|
Puts a link on a rectangular area of the page. Text or image links are generally put via cell(), write() or 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:
multiCell [line 1976]
void multiCell(
float
$width, float
$height, string
$text, [mixed
$border = 0], [string
$align = 'J'], [integer
$fill = 0])
|
|
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:
newLine [line 2393]
void newLine(
[float
$height = ''])
|
|
Performs a line break. The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter.
Parameters:
open [line 861]
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 addPage().
output [line 2547]
void output(
[string
$filename = 'unknown.pdf'], [boolean
$inline = false])
|
|
Sends the buffered data to the browser.
Parameters:
raiseError [line 609]
object PEAR_Error raiseError(
mixed
$error)
|
|
Returns a PEAR_Error object. Wraps around PEAR::raiseError() to avoid having to include PEAR.php unless an error occurs.
Parameters:
rect [line 1299]
void rect(
float
$x, float
$y, float
$width, float
$height, [float
$style = ''])
|
|
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:
save [line 2586]
void save(
[string
$filename = 'unknown.pdf'])
|
|
Saves the PDF file on the filesystem.
Parameters:
setAutoPageBreak [line 722]
void setAutoPageBreak(
boolean
$auto, [float
$margin = 0])
|
|
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:
setCompression [line 787]
void setCompression(
boolean
$compress)
|
|
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:
setDisplayMode [line 753]
void setDisplayMode(
mixed
$zoom, [string
$layout = 'continuous'])
|
|
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:
setDrawColor [line 1182]
void setDrawColor(
[string
$cs = 'rgb'], float
$c1, [float
$c2 = 0], [float
$c3 = 0], [float
$c4 = 0])
|
|
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:
setFillColor [line 1101]
void setFillColor(
[string
$cs = 'rgb'], float
$c1, [float
$c2 = 0], [float
$c3 = 0], [float
$c4 = 0])
|
|
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:
setFont [line 1529]
void setFont(
string
$family, [string
$style = ''], [integer
$size = null], [boolean
$force = false])
|
|
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 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 setFontSize().
Parameters:
setFontSize [line 1612]
void setFontSize(
float
$size)
|
|
Defines the size of the current font.
Parameters:
setFontStyle [line 1638]
void setFontStyle(
string
$style)
|
|
Defines the style of the current font.
Parameters:
setInfo [line 809]
void setInfo(
array|string
$info, [string
$value = ''])
|
|
Set the info to a document. Possible info settings are: - title
- subject
- author
- keywords
- creator
Parameters:
setLeftMargin [line 652]
void setLeftMargin(
float
$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:
setLineWidth [line 1238]
void setLineWidth(
float
$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:
setLink [line 1678]
void setLink(
integer
$link, [float
$y = 0], [integer
$page = -1])
|
|
Defines the page and position a link points to.
Parameters:
setMargins [line 630]
void setMargins(
float
$left, float
$top, [float
$right = null])
|
|
Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them.
Parameters:
setRightMargin [line 681]
void setRightMargin(
float
$margin)
|
|
Defines the right margin. The method can be called before creating the first page.
Parameters:
setTextColor [line 1144]
void setTextColor(
string
$cs, float
$c1, [float
$c2 = 0], [float
$c3 = 0], [float
$c4 = 0])
|
|
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:
setTopMargin [line 669]
void setTopMargin(
float
$margin)
|
|
Defines the top margin. The method can be called before creating the first page.
Parameters:
setX [line 2430]
Defines the abscissa of the current position. If the passed value is negative, it is relative to the right of the page.
Parameters:
setXY [line 2491]
void setXY(
float
$x, float
$y)
|
|
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:
setY [line 2468]
Defines the ordinate of the current position. If the passed value is negative, it is relative to the bottom of the page.
Parameters:
text [line 1751]
void text(
float
$x, float
$y, string
$text)
|
|
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 cell(), multiCell() or 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:
write [line 2132]
void write(
float
$height, string
$text, [mixed
$link = ''])
|
|
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:
writeRotated [line 2239]
void writeRotated(
integer
$x, integer
$y, string
$text, float
$text_angle, [float
$font_angle = 0])
|
|
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:
Documentation generated on Mon, 11 Mar 2019 15:44:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|