Свойство | Type | Description | |
---|---|---|---|
$fh | float | Current height of page format in user units. | |
$fhPt | float | Current height of page format in points. | |
$fw | float | Current width of page format in user units. | |
$fwPt | float | Current width of page format in points. | |
$h | float | Current height of page in user units | |
$hPt | float | Current height of page in points. | |
$w | float | Current width of page in user units | |
$wPt | float | Current width of page in points. | |
$x | float | Value is set in user units and is calculated from the top left corner as origin. | |
$y | float | Value is set in user units and is calculated from the top left corner as origin. |
Свойство | Type | Description | |
---|---|---|---|
$_alias_nb_pages | string | Alias for total number of pages. | |
$_auto_page_break | boolean | Automatic page breaking. | |
$_break_margin | float | Break page margin size, the bottom margin which triggers a page break. | |
$_buffer | string | Buffer holding in-memory Pdf. | |
$_buflen | integer | Buffer length, including already flushed content. | |
$_cell_margin | float | Cell margin size. | |
$_color_flag | boolean | Whether text color is different from fill color. | |
$_compress | boolean | Flag indicating if PDF file is to be compressed or not. | |
$_core_fonts | array | An array of standard font names. | |
$_current_font | array | An array containing current font info. | |
$_current_orientation | string | The current page orientation. | |
$_default_orientation | string | The default page orientation. | |
$_diffs | array | An array of encoding differences. | |
$_draw_color | string | Commands for drawing color. | |
$_fill_color | string | Commands for filling color. | |
$_flushed | boolean | Whether the buffer has been flushed already. | |
$_font_family | string | Current font family. | |
$_font_files | array | An array of font files. | |
$_font_size | float | Current font size in user units. | |
$_font_size_pt | float | Current font size in points. | |
$_font_style | string | Current font style. | |
$_font_widths | array | Widths of specific font files | |
$_fonts | array | An array of used fonts. | |
$_images | array | An array of used images. | |
$_in_footer | boolean | Flag set when processing footer. | |
$_info | array | An array containing the document info, consisting of: - title - subject - author - keywords - creator | |
$_last_height | float | The height of the last cell printed. | |
$_layout_mode | string | Layout display mode. | |
$_left_margin | float | Left page margin size. | |
$_line_width | float | Line width in user units. | |
$_links | array | An array of internal links. | |
$_n | integer | Current object number. | |
$_offsets | array | Array of object offsets. | |
$_orientation_changes | array | Array indicating orientation changes. | |
$_page | integer | Current page number. | |
$_page_break_trigger | float | Threshold used to trigger page breaks. | |
$_page_links | array | An array of links in pages. | |
$_pages | array | Array containing the pages. | |
$_right_margin | float | Right page margin size. | |
$_scale | float | Scale factor (number of points in user units). | |
$_state | integer | Current document state.0 - initial state 1 - document opened 2 - page opened 3 - document closed |
|
$_text_color | string | Commands for text color. | |
$_top_margin | float | Top page margin size. | |
$_underline | boolean | Underlining flag. | |
$_word_spacing | integer | Word spacing. | |
$_zoom_mode | string | Zoom display mode. |
Méthode | Description | |
---|---|---|
__construct ( array $params = [] ) | Constructor | |
acceptPageBreak ( ) : boolean | 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 {@link setAutoPageBreak()}. | |
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. | |
addLink ( ) | Creates a new internal link and returns its identifier. | |
addPage ( string $orientation = '' ) | Adds a new page to the document. | |
aliasNbPages ( string $alias = '{nb}' ) | Defines an alias for the total number of pages. | |
cell ( float $width, float $height, string $text = '', mixed $border, integer $ln, string $align = '', integer $fill, string $link = '' ) | Prints a cell (rectangular area) with optional borders, background color and character string. | |
circle ( float $x, float $y, float $r, string $style = '' ) | Outputs a circle. It can be drawn (border only), filled (with no border) or both. | |
close ( ) | Terminates the PDF document. | |
flush ( ) | Returns the current buffer content and resets the buffer. | |
footer ( ) | This method is used to render the page footer. | |
getDefaultOrientation ( ) : string | P (portrait) or L (landscape) | |
getDrawColor ( ) : string | Get the draw color | |
getFillColor ( ) : string | Get the fill color | |
getFormatHeight ( ) : float | ||
getFormatWidth ( ) : float | ||
getOutput ( ) | Returns the raw Pdf file. | |
getPage ( ) : integer | Get the current page | |
getPageHeight ( ) : float | Returns the actual page height. | |
getPageNo ( ) : integer | Returns the current page number. | |
getPageWidth ( ) : float | Returns the actual page width. | |
getScale ( ) : integer | ||
getStringWidth ( string $text, boolean $pt = false ) : float | Returns the length of a text string. A font must be selected. | |
getTextColor ( ) : string | Get the text color | |
getX ( ) : float | Returns the abscissa of the current position in user units. | |
getY ( ) : float | Returns the ordinate of the current position in user units. | |
header ( ) | This method is used to render the page header. | |
image ( string $file, float $x, float $y, float $width, float $height, string $type = '', mixed $link = '' ) | Prints an image in the page. | |
line ( float $x1, float $y1, float $x2, float $y2 ) | Draws a line between two points. | |
link ( float $x, float $y, float $width, float $height, mixed $link ) | Puts a link on a rectangular area of the page. | |
multiCell ( float $width, float $height, string $text, mixed $border, string $align = 'J', integer $fill ) | This method allows printing text with line breaks. | |
newLine ( float $height = '' ) | Performs a line break. | |
open ( ) | This method begins the generation of the PDF document; it must be called before any output commands. | |
rect ( float $x, float $y, float $width, float $height, float $style = '' ) | Outputs a rectangle. | |
save ( string $filename = 'unknown.pdf' ) | Saves the PDF file on the filesystem. | |
setAutoPageBreak ( boolean $auto, float $margin ) | Enables or disables the automatic page breaking mode. | |
setCompression ( boolean $compress ) | Activates or deactivates page compression. | |
setDisplayMode ( mixed $zoom, $layout = 'continuous' ) | Defines the way the document is to be displayed by the viewer. | |
setDrawColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | Sets the draw color, used when drawing lines. | |
setFillColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | Sets the fill color. | |
setFont ( string $family, string $style = '', integer $size = null, boolean $force = false ) | Sets the font used to print character strings. | |
setFontSize ( float $size ) | Defines the size of the current font. | |
setFontStyle ( string $style ) | Defines the style of the current font. | |
setInfo ( array | string $info, string $value = '' ) | Set the info to a document. | |
setLeftMargin ( float $margin ) | Defines the left margin. | |
setLineWidth ( float $width ) | Defines the line width. | |
setLink ( integer $link, float $y, integer $page ) | Defines the page and position a link points to. | |
setMargins ( float $left, float $top, float $right = null ) | Defines the left, top and right margins. | |
setPage ( integer $page ) | Set the current page | |
setRightMargin ( float $margin ) | Defines the right margin. | |
setTextColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | Sets the text color. | |
setTopMargin ( float $margin ) | Defines the top margin. | |
setX ( float $x ) | Defines the abscissa of the current position. | |
setXY ( float $x, float $y ) | Defines the abscissa and ordinate of the current position. | |
setY ( float $y ) | Defines the ordinate of the current position. | |
text ( float $x, float $y, string $text ) | Prints a character string. | |
write ( float $height, string $text, mixed $link = '' ) | This method prints text from the current position. | |
writeRotated ( integer $x, integer $y, string $text, float $text_angle, float $font_angle ) | Writes text at an angle. |
Méthode | Description | |
---|---|---|
_beginDoc ( ) : void | Begin the PDF document. | |
_beginPage ( string $orientation ) : void | Begin a new page. | |
_doUnderline ( integer $x, integer $y, string $text ) : string | Underline a block of text. | |
_endDoc ( ) : void | End the PDF document | |
_endPage ( ) : void | Set the end of page contents. | |
_escape ( string $s ) : string | Escape parentheses and forward slash. | |
_freadInt ( resource $f ) : integer | Read a 4-byte integer from stream. | |
_getFontFile ( string $fontkey ) : array | Load information about a font from its key name. | |
_hexToRgb ( $hex ) | Convert hex-based color to RGB | |
_link ( integer $x, integer $y, integer $width, integer $height, string $link ) : void | Save link to page links array. | |
_newobj ( ) : void | Begin a new object. | |
_out ( string $s ) : void | Add a line to the document. | |
_parseJPG ( string $file ) : array | Extract info from a JPEG file. | |
_parsePNG ( string $file ) : array | Extract info from a PNG file. | |
_putCatalog ( ) : void | Write the PDF catalog. | |
_putFonts ( ) : void | Write the PDF fonts. | |
_putImages ( ) : void | Write the PDF images. | |
_putInfo ( ) : void | Write the PDF information. | |
_putPages ( ) : void | Write the PDF pages. | |
_putResources ( ) : void | Write the PDF resources. | |
_putStream ( string $s ) : void | Add a line to the document wrapped in 'stream' and 'endstream'. | |
_putTrailer ( ) : void | Write the PDF trailer. | |
_textString ( string $s ) : string | Format a text string by escaping and wrapping in parentheses. | |
_toPt ( integer $val ) : integer | Scale a value. |
$pdf = new Horde_Pdf_Writer(array('orientation' => 'P',
'unit' => 'mm',
'format' => 'A4'));
public __construct ( array $params = [] ) | ||
$params | array | 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). |
protected _beginPage ( string $orientation ) : void | ||
$orientation | string | Orientation code |
Résultat | void |
protected static _getFontFile ( string $fontkey ) : array | ||
$fontkey | string | Font name key |
Résultat | array | Array of all font widths, including this font. |
protected _putCatalog ( ) : void | ||
Résultat | void |
protected _putResources ( ) : void | ||
Résultat | void |
protected _putStream ( string $s ) : void | ||
$s | string | Line to add. |
Résultat | void |
protected _putTrailer ( ) : void | ||
Résultat | void |
protected _textString ( string $s ) : string | ||
$s | string | String to format. |
Résultat | string |
public acceptPageBreak ( ) : boolean | ||
Résultat | boolean |
$pdf->addFont('Comic', 'I');
is equivalent to:
$pdf->addFont('Comic', 'I', 'comici.php');
public addFont ( string $family, string $style = '', string $file = '' ) | ||
$family | string | Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font. |
$style | string | Font style. Possible values are (case insensitive): - empty string: regular (default) - B: bold - I: italic - BI or IB: bold italic |
$file | string | The font definition file. By default, the name is built from the family and style, in lower case with no space. |
public addLink ( ) |
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();
public aliasNbPages ( string $alias = '{nb}' ) | ||
$alias | string | The alias. |
public cell ( float $width, float $height, string $text = '', mixed $border, integer $ln, string $align = '', integer $fill, string $link = '' ) | ||
$width | float | Cell width. If 0, the cell extends up to the right margin. |
$height | float | Cell height. |
$text | string | String to print. |
$border | mixed | 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 |
$ln | integer | 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 {@link newLine()} just after. |
$align | string | Allows to center or align the text. Possible values are: - L or empty string: left (default) - C: center - R: right |
$fill | integer | Indicates if the cell fill type. Possible values are: - 0: transparent (default) - 1: painted |
$link | string | URL or identifier returned by {@link addLink()}. |
public circle ( float $x, float $y, float $r, string $style = '' ) | ||
$x | float | Abscissa of the center of the circle. |
$y | float | Ordinate of the center of the circle. |
$r | float | Circle radius. |
$style | string | Style of rendering. Possible values are: - D or empty string: draw (default) - F: fill - DF or FD: draw and fill |
public close ( ) |
public flush ( ) |
public getDefaultOrientation ( ) : string | ||
Résultat | string |
public getPageHeight ( ) : float | ||
Résultat | float | The page height. |
public getPageWidth ( ) : float | ||
Résultat | float | The page width. |
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);
}
}
public header ( ) |
public image ( string $file, float $x, float $y, float $width, float $height, string $type = '', mixed $link = '' ) | ||
$file | string | Name of the file containing the image. |
$x | float | Abscissa of the upper-left corner. |
$y | float | Ordinate of the upper-left corner. |
$width | float | Width of the image in the page. If equal to zero, it is automatically calculated to keep the original proportions. |
$height | float | Height of the image in the page. If not specified or equal to zero, it is automatically calculated to keep the original proportions. |
$type | string | Image format. Possible values are (case insensitive): JPG, JPEG, PNG. If not specified, the type is inferred from the file extension. |
$link | mixed | URL or identifier returned by {@link addLink()}. |
public link ( float $x, float $y, float $width, float $height, mixed $link ) | ||
$x | float | Abscissa of the upper-left corner of the rectangle. |
$y | float | Ordinate of the upper-left corner of the rectangle. |
$width | float | Width of the rectangle. |
$height | float | Height of the rectangle. |
$link | mixed | URL or identifier returned by {@link addLink()}. |
public multiCell ( float $width, float $height, string $text, mixed $border, string $align = 'J', integer $fill ) | ||
$width | float | Width of cells. If 0, they extend up to the right margin of the page. |
$height | float | Height of cells. |
$text | string | String to print. |
$border | mixed | 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 |
$align | string | Sets the text alignment. Possible values are: - L: left alignment - C: center - R: right alignment - J: justification (default value) |
$fill | integer | Indicates if the cell background must: - 0: transparent (default) - 1: painted |
public open ( ) |
public rect ( float $x, float $y, float $width, float $height, float $style = '' ) | ||
$x | float | Abscissa of upper-left corner. |
$y | float | Ordinate of upper-left corner. |
$width | float | Width. |
$height | float | Height. |
$style | float | Style of rendering. Possible values are: - D or empty string: draw (default) - F: fill - DF or FD: draw and fill |
public setAutoPageBreak ( boolean $auto, float $margin ) | ||
$auto | boolean | Boolean indicating if mode should be on or off. |
$margin | float | Distance from the bottom of the page. |
public setCompression ( boolean $compress ) | ||
$compress | boolean | Boolean indicating if compression must be enabled or not. |
public setDisplayMode ( mixed $zoom, $layout = 'continuous' ) | ||
$zoom | mixed | 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. |
public setDrawColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | ||
$cs | string | Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk' or 'gray'. Defaults to 'rgb'. |
$c1 | float | First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk. |
$c2 | float | Second color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c3 | float | Third color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c4 | float | Fourth color component, floating point value between 0 and 1. Required for cmyk. |
public setFillColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | ||
$cs | string | Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk', or 'gray'. Defaults to 'rgb'. |
$c1 | float | First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk. |
$c2 | float | Second color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c3 | float | Third color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c4 | float | Fourth color component, floating point value between 0 and 1. Required for cmyk. |
public setFont ( string $family, string $style = '', integer $size = null, boolean $force = false ) | ||
$family | string | Family font. It can be either a name defined by {@link addFont()} 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. |
$style | string | 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. |
$size | integer | 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. |
$force | boolean | Force the setting of the font. Each new page will require a new call to {@link setFont()} and setting this to true will make sure that the checks for same font calls will be skipped. |
public setFontSize ( float $size ) | ||
$size | float | The size (in points). |
public setFontStyle ( string $style ) | ||
$style | string | The font style. |
public setLeftMargin ( float $margin ) | ||
$margin | float | The margin. |
public setLineWidth ( float $width ) | ||
$width | float | The width. |
public setLink ( integer $link, float $y, integer $page ) | ||
$link | integer | The link identifier returned by {@link addLink()}. |
$y | float | Ordinate of target position; -1 indicates the current position. The default value is 0 (top of page). |
$page | integer | Number of target page; -1 indicates the current page. |
public setRightMargin ( float $margin ) | ||
$margin | float | The margin. |
public setTextColor ( string $cs = 'rgb', float $c1, float $c2, float $c3, float $c4 ) | ||
$cs | string | Indicates the colorspace which can be either 'rgb', 'hex', 'cmyk' or 'gray'. Defaults to 'rgb'. |
$c1 | float | First color component, floating point value between 0 and 1. Required for gray, rgb and cmyk. |
$c2 | float | Second color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c3 | float | Third color component, floating point value between 0 and 1. Required for rgb and cmyk. |
$c4 | float | Fourth color component, floating point value between 0 and 1. Required for cmyk. |
public setTopMargin ( float $margin ) | ||
$margin | float | The margin. |
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');
protected string $_alias_nb_pages | ||
Résultat | string |
protected bool $_auto_page_break | ||
Résultat | boolean |
protected float $_break_margin | ||
Résultat | float |
protected string $_buffer | ||
Résultat | string |
protected int $_buflen | ||
Résultat | integer |
protected bool $_color_flag | ||
Résultat | boolean |
protected bool $_compress | ||
Résultat | boolean |
protected array $_core_fonts | ||
Résultat | array |
protected array $_current_font | ||
Résultat | array |
protected string $_current_orientation | ||
Résultat | string |
protected string $_default_orientation | ||
Résultat | string |
protected array $_diffs | ||
Résultat | array |
protected string $_draw_color | ||
Résultat | string |
protected string $_fill_color | ||
Résultat | string |
protected bool $_flushed | ||
Résultat | boolean |
protected string $_font_family | ||
Résultat | string |
protected array $_font_files | ||
Résultat | array |
protected float $_font_size | ||
Résultat | float |
protected float $_font_size_pt | ||
Résultat | float |
protected string $_font_style | ||
Résultat | string |
protected static array $_font_widths | ||
Résultat | array |
protected array $_info | ||
Résultat | array |
protected float $_last_height | ||
Résultat | float |
protected string $_layout_mode | ||
Résultat | string |
protected float $_left_margin | ||
Résultat | float |
protected float $_line_width | ||
Résultat | float |
protected array $_orientation_changes | ||
Résultat | array |
protected float $_page_break_trigger | ||
Résultat | float |
protected array $_page_links | ||
Résultat | array |
protected float $_right_margin | ||
Résultat | float |
protected float $_scale | ||
Résultat | float |
0 - initial state 1 - document opened 2 - page opened 3 - document closed
protected int $_state | ||
Résultat | integer |
protected string $_text_color | ||
Résultat | string |
protected float $_top_margin | ||
Résultat | float |
public float $x | ||
Résultat | float |
public float $y | ||
Résultat | float |