SOURCE

FPDF.php

Classes


FPDF

class FPDF
      |  
      `--PdfObjWriterInterface

{

PDF document generator. This source is based on a work of Olivier Plathey (FPDF 1.7) plus support for external TrueType font by Ian Back (tFPDF 1.24), here adapted to pass the validation of PHPLint. This class can generate a PDF 1.3 file with embedded fonts and images. Unicode strings are supported through the UString class.

This example generates a simple document:

	require_once 'utf8.php'; # provides the u() function
	use it\icosaedro\fpdf\FPDF;
	$pdf = new FPDF();
	$pdf->addPage();
	$pdf->cell(40,10,u('Hello World!'));
	$pdf->output('hello.pdf', 'F');

More examples are available under the directory test/stdlib/org/fpdf of the PHPLint package. They illustrates how fonts and styles can be applied to text; how text can be formatted in pages with header, footer and page numbers; tables; images; internal and external links.

Fonts are supported as external objects FontCore and FontTrueType.
Version: $Date: 2019/01/10 09:02:13 $
Author: Olivier Plathey (original author of FPDF)
Author: Ian Back <ianb@bpm1.com> (Unicode and TrueType support)
Author: Umberto Salsi <salsi@icosaedro.it> (porting to PHPLint)
Copyright: Permission is hereby granted, free of charge, to any person obtaining a copy of this software to use, copy, modify, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.

Class constants


PDF_VERSION

public PDF_VERSION = "1.3"

Version of the generated PDF code.


VERSION

public VERSION = "\$Date: 2019/01/10 09:02:13 \$"

Properties


$aliasNbPages

protected string $aliasNbPages

Alias for total number of pages.


$autoPageBreak

protected boolean $autoPageBreak

Automatic page breaking.


$bMargin

public float $bMargin

Page break margin.


$cMargin

public float $cMargin

Cell margin.


$colorFlag

protected boolean $colorFlag

Indicates whether fill and text colors are different.


$compress

protected boolean $compress

Compression flag.


$coreFonts

public string[int] $coreFonts

Array of core font names.


$curOrientation

public string $curOrientation

Orientation of the current page.


$curPageSize

public float[int] $curPageSize

Size of the current page in portrait orientation (pt).


$currentFont

public Font $currentFont

Current font.


$defOrientation

public string $defOrientation

Orientation used for new added pages.


$defPageSize

public float[int] $defPageSize

Page size used for new added pages, in portrait orientation (pt).


$drawColor

protected string $drawColor

Commands for drawing color.


$fillColor

protected string $fillColor

Commands for filling color.


$fontSize

public float $fontSize

Current font size in user unit.


$fontSizePt

public float $fontSizePt

Current font size in points.


$fontStyle

public string $fontStyle

Current font style.


$fonts

protected HashMap $fonts

Used fonts; key and value are the font.


$h

public float $h

Height of the current page, accounting for the current page orientation (user's units).


$images

protected HashMap $images

Embedded images; key and value are the image.


$inFooter

protected boolean $inFooter

Flag set when processing footer.


$inHeader

protected boolean $inHeader

Flag set when processing header.


$k

public float $k

Scale factor (number of points in user unit).


$lMargin

public float $lMargin

Left margin.


$lasth

protected float $lasth

Height of last printed cell.


$layoutMode

protected string $layoutMode

Layout display mode.


$lineWidth

protected float $lineWidth

Line width in user unit.


$n

protected int $n

Current object number.


$offsets

protected int[int] $offsets

Array of object offsets in the destination PDF buffer.


$page

protected int $page

Current page number.


$pageBreakTrigger

public float $pageBreakTrigger

Threshold used to trigger page breaks.


$pageSizes

public float[int][int] $pageSizes

Each page size, accounting for its orientation (pt). First index is the page number starting from 1.


$rMargin

public float $rMargin

Right margin.


$state

protected int $state

Current document state, see STATE_* constants.


$stdPageSizes

public float[string][int] $stdPageSizes

Standard page sizes (pt).


$tMargin

public float $tMargin

Top margin.


$textColor

protected string $textColor

Commands for text color.


$underline

public boolean $underline

Underlining flag.


$w

public float $w

Width of the current page, accounting for the current page orientation (user's units).


$ws

protected float $ws

Word spacing.


$x

protected float $x

Current position (user's units).


$y

protected float $y

Current position (user's units).


$zoomMode

protected mixed $zoomMode

Display mode in viewer: 'fullpage', 'fullwidth', 'real', 'default' or a double number.

Methods


__construct()

public void __construct() throws ErrorException

Initializes a new empty PDF document. The default page size is A4 in portrait orientation. The default measurement unit is mm. The default font is Courier 12 pt. A new page MUST be added before starting putting text in the document.


acceptPageBreak()

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 setAutoPageBreak(). This method is called automatically and should not be called directly by the application. In this example the method is overridden in an inherited class in order to obtain a 3 column layout:

	require_once 'utf8.php'; # provides the u() function
	class PDF extends FPDF
	{
		var $col = 0;

		function setCol($col)
		{
			// Move position to a column
			$this->col = $col;
			$x = 10+$col*65;
			$this->setLeftMargin($x);
			$this->setX($x);
		}

		function acceptPageBreak()
		{
			if($this->col<2)
			{
				// Go to next column
				$this->setCol($this->col+1);
				$this->setY(10);
				return false;
			}
			else
			{
				// Go back to first column and issue page break
				$this->setCol(0);
				return true;
			}
		}
	}

	$pdf = new PDF();
	$pdf->addPage();
	for($i=1;$i<=300;$i++)
		$pdf->cell(0,5,u("Line $i"),0,1);
	$pdf->output();

See also: FPDF::setAutoPageBreak().


addField()

public void addField(Field $f)

Adds an Acrobat Form field to the current page.
Deprecated. Feature not supported yet.


addLink()

public int addLink()

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(), write(), image() or link(). The destination is defined with setLink(). See also: FPDF::cell(), FPDF::write(), FPDF::image(), FPDF::link(), FPDF::setLink().
Return: Generated internal link number.


addObj()

public int addObj()
Implements PdfObjWriterInterface::addObj()

Begin a new object. For internal use; should not be called by user's application.


addPage()

public void addPage() throws ErrorException

Adds a new page to the document. If a page is already present, the FPDF::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 FPDF::header() is called to display the header. The font which was set before calling is automatically restored. There is no need to call FPDF::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.
See also: FPDF::header(), FPDF::footer(), FPDF::setMargins().


aliasNbPages()

public void aliasNbPages(string $alias = "{nb}")

Defines a placeholder string for the total number of pages. It will be substituted as the document is closed and the actual total number of pages is known. Example:

	require_once 'utf8.php'; # provides the u() function
	class PDF extends FPDF
	{
		function footer()
		{
			// Select Helvetica bold 15
			$this->setFont(FontCore('helvetica', true, false),'',15);
			// Go to 1.5 cm from bottom
			$this->setY(-15);
			// Print current and total page numbers
			$this->cell(0,10,u('Page '.$this->pageNo().'/{nb}'),0,0,'C');
		}
	}

	$pdf = new PDF();
	$pdf->aliasNbPages();

See also: FPDF::pageNo(), FPDF::footer().
Parameters:
$alias - The alias. Default value: {nb}.


cell()

public void cell(float $w, float $h = 0.0, UString $txt = NULL, mixed $border = 0, int $ln = 0, string $align = "", boolean $fill = FALSE, mixed $link = NULL) throws ErrorException

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. Example:

require_once 'utf8.php'; # provides the u() function
// Set font
$pdf->setFont(FontCore::factory("helvetica", true, false),'',16);
// Move to 8 cm to the right
$pdf->cell(80);
// Centered text in a framed 20*10 mm cell and line break
$pdf->cell(20,10,u('Title'),1,1,'C');
See also: FPDF::setFont(), FPDF::setDrawColor(), FPDF::setFillColor(), FPDF::setTextColor(), FPDF::setLineWidth(), FPDF::addLink(), FPDF::ln(), FPDF::multiCell(), FPDF::write(), FPDF::setAutoPageBreak().
Parameters:
$w - Cell width. If 0, the cell extends up to the right margin.
$h - Cell height. Default value: 0.
$txt - String to print.
$border - Indicates if borders must be drawn around the cell. The value can be either a number: or a string containing some or all of the following characters (in any order): Default value: 0.
$ln - Indicates where the current position should go after the call. Possible values are: Putting 1 is equivalent to putting 0 and calling ln() just after. Default value: 0.
$align - Allows to center or align the text. Possible values are:
$fill - Indicates if the cell background must be painted (true) or transparent (false). Default value: false.
$link - URL or identifier returned by FPDF::addLink().
Throws:
ErrorException - This exception comes from the signature of Footer() and Header(). In fact, a page break can cause a call to AddPage() which, in turn, calls these methods.

close()

public void close() throws ErrorException

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

See also: FPDF::output().


footer()

public void footer() throws ErrorException

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 FPDF is empty, so you have to subclass it and override the method if you want a specific processing. Example:

	class PDF extends FPDF
	{
		function footer()
		{
			// Go to 1.5 cm from bottom
			$this->setY(-15);
			// Select Helvetica italic 8
			$this->setFont(FontCore('helvetica', false, true),'',8);
			// Print centered page number
			$this->cell(0,10,'Page '.$this->pageNo(),0,0,'C');
		}
	}

See also: FPDF::header().


getX()

public float getX()

Returns the abscissa of the current position.

See also: FPDF::setX(), FPDF::getY(), FPDF::setY().


getY()

public float getY()

Returns the ordinate of the current position.

See also: FPDF::setY(), FPDF::getX(), FPDF::setX().


header()

public void header() throws ErrorException

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 FPDF is empty, so you have to subclass it and override the method if you want a specific header formatting. Example:

	require_once 'utf8.php'; # provides the u() function
	class PDF extends FPDF
	{
		function header()
		{
			// Select Helvetica bold 15
			$this->setFont(FontCore('helvetica', true, false),'',15);
			// Move to the right
			$this->cell(80);
			// Framed title
			$this->cell(30,10,u('Title'),1,0,'C');
			// Line break
			$this->ln(20);
		}
	}

See also: FPDF::footer().


image()

public void image(Image $image, float $x = 0.0, float $y = 0.0, float $w = 0.0, float $h = 0.0, string $link = "") throws ErrorException

Puts an image in the document. The size it will take on the page can be specified in different ways:

Supported formats are JPEG, PNG and GIF. The GD extension is required for GIF.

For JPEGs, all flavors are allowed:

For PNGs, are allowed:

For GIFs: in case of an animated GIF, only the first frame is displayed.

Transparency is supported.

It is possible to put a link on the image.

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

The current position after the image has been inserted is its bottom right corner.

Example:

// Insert a logo in the top-left corner at 300 dpi
$img = Image::fromFile(File::fromLocaleEncoded('logo.png'));
$pdf->image($img,10,10,-300);
The same image can be put in the document several times, for example in every header. The binary content of the image shall be embedded in the PDF document only once.

See alse: FPDF::addLink().
Parameters:
$image - The image to put in the page.
$x - Abscissa of the upper-left corner. If not specified or equal to null, the current abscissa is used.
$y - Ordinate of the upper-left corner. If not specified or equal to null, the current ordinate is used; moreover, a page break is triggered first if necessary (in case automatic page breaking is enabled) and, after the call, the current ordinate is moved to the bottom of the image.
$w - Width of the image in the page. There are three cases:


$h - Height of the image in the page. There are three cases:
$link - URL or identifier returned by FPDF::addLink().
Throws:
ErrorException - Automatic page break may trigger a call to the page header and page footer methods, which are allowed to throw exception.

line()

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

Draws a line between two points.

See also: FPDF::setLineWidth(), FPDF::setDrawColor().
Parameters:
$x1 - Abscissa of first point.
$y1 - Ordinate of first point.
$x2 - Abscissa of second point.
$y2 - Ordinate of second point.


link()

public void link(float $x, float $y, float $w, float $h, mixed $link)

Puts a link on a rectangular area of the page. Text or image links are generally put via FPDF::cell(), FPDF::write() or FPDF::image(), but this method can be useful for instance to define a clickable area inside an image.
Parameters:
$x - Abscissa of the upper-left corner of the rectangle.
$y - Ordinate of the upper-left corner of the rectangle.
$w - Width of the rectangle.
$h - Height of the rectangle.
$link - URL or identifier returned by FPDF::addLink().


ln()

public void ln(float $h = -1.0)

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

See also: FPDF::cell().
Parameters:
$h - The height of the break. By default, the value equals the height of the last printed cell.


multiCell()

public void multiCell(float $w, float $h, UString $txt, mixed $mixed_border = 0, string $align = "J", boolean $fill = FALSE) throws ErrorException

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.

See also: FPDF::setFont(), FPDF::setDrawColor(), FPDF::setFillColor(), FPDF::setTextColor(), FPDF::setLineWidth(), FPDF::cell(), FPDF::write(), FPDF::setAutoPageBreak().
Parameters:
$w - Width of cells. If 0, they extend up to the right margin of the page.
$h - Height of cells.
$txt - String to print.
$mixed_border - Indicates if borders must be drawn around the cell block. The value can be either a number:

or a string containing some or all of the following characters (in any order): Default value: 0.
$align - Sets the text alignment. Possible values are:
$fill - Indicates if the cell background must be painted (true) or transparent (false). Default value: false.

output()

public string output(string $name = "", string $dest = "") throws ErrorException, InvalidArgumentException

Send the document to a given destination: browser, file or string. In the case of browser, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced. The method first calls close() if necessary to terminate the document.
Parameters:
$name - The name of the file. If not specified, the document will be sent to the browser (destination I) with the name doc.pdf.
$dest - Destination where to send the document. It can take one of the following values:

See also: FPDF::close().
Return: The empty string or the PDF contents, depending on the previous parameters.
Throws:
InvalidArgumentException - Invalid output destination.


pageNo()

public int pageNo()

Returns the current page number.

See also: FPDF::aliasNbPages().
Return: Number of the current page, or zero if no page has been created yet.


put()

public void put(string $s)
Implements PdfObjWriterInterface::put()

Add a line to the document. For internal use; should not be called by user's application.


putStream()

public void putStream(string $s)
Implements PdfObjWriterInterface::putStream()

For internal use only; should not be called by user's application.


rect()

public void rect(float $x, float $y, float $w, float $h, string $style = "")

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

See also: FPDF::setLineWidth(), FPDF::setDrawColor(), FPDF::setFillColor().
Parameters:
$x - Abscissa of upper-left corner.
$y - Ordinate of upper-left corner.
$w - Width.
$h - Height.
$style - Style of rendering. Possible values are:



setAuthor()

public void setAuthor(UString $author)

Defines the author of the document.
Parameters:
$author - The name of the author.


setAutoPageBreak()

public boolean setAutoPageBreak(boolean $auto, float $margin = 0.0)

Enables or disables the automatic page breaking mode. When enabled, 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.

See also: FPDF::cell(), FPDF::multiCell(), FPDF::acceptPageBreak().
Parameters:
$auto - If mode should be on or off.
$margin - Distance from the bottom of the page.
Return: Current status of the auto page break feature.


setCompression()

public 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.
Parameters:
$compress - If compression must be enabled.


setCreator()

public void setCreator(UString $creator)

Defines the creator of the document. If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted.
Parameters:
$creator - The name of the creator.


setDisplayMode()

public void setDisplayMode(string $zoom, string $layout = "default") throws InvalidArgumentException

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 Adobe Reader). The page layout can be specified too: single at once, continuous display, two columns or viewer default.
Parameters:
$zoom - The zoom to use. It can be one of the following string values:

or a number indicating the zooming factor to use.
$layout - The page layout. Possible values are: Default value is default.
Throws:
InvalidArgumentException - Invalid $zoom. Invalid $layout.

setDrawColor()

public void setDrawColor(int $r, int $g, int $b)

Defines the color used for all drawing operations (lines, rectangles and cell borders). The method can be called before the first page is created and the value is retained from page to page.

See also: FPDF::setFillColor(), FPDF::setTextColor(), FPDF::line(), FPDF::rect(), FPDF::cell(), FPDF::multiCell().
Parameters:
$r - Red component (between 0 and 255).
$g - Green component (between 0 and 255).
$b - Blue component (between 0 and 255).


setFillColor()

public void setFillColor(int $r, int $g, int $b)

Defines the color used for all filling operations (filled rectangles and cell backgrounds). The method can be called before the first page is created and the value is retained from page to page.

See also: FPDF::setDrawColor(), FPDF::setTextColor(), FPDF::rect(), FPDF::cell(), FPDF::multiCell().
Parameters:
$r - Red component (between 0 and 255).
$g - Green component (between 0 and 255).
$b - Blue component (between 0 and 255).


setFont()

public void setFont(Font $font, string $style = "", float $size = 0.0)

Sets the font used to print character strings. The font object belongs to an abstract class; currently 2 implementations are available: font core and font TrueType. Core fonts are already embedded in any PDF reader, so they are not added to the generated document. TrueType fonts, on the contrary have to embedded in the generated document; to reduce the occupied space, only the characters actually put in the document are copied in the file.
The same font can be set several times: it will be added to the document only once.
This method can be called before the first page is created and the font is kept from page to page.
If you just wish to change the current font size, it is simpler to call FPDF::setFontSize(). Example:

	// Times regular 12
	$this->setFont(FontCore('times', false, false),'',12);
	// Helvetica bold 14
	$this->setFont(FontCore('helvetica', true, false),'',14);
	// Times bold, italic and underlined 14
	$this->setFont(FontCore('helvetica', true, true),'U',14);
	// TrueType font underlined 12:
	$font = new FontTrueType(File::fromLocalEncoded(__DIR__.'/MyFont.ttf'));
	$this->setFont($font,'U',14);

See also: FPDF::setFontSize(), FPDF::cell(), FPDF::multiCell(), FPDF::write().
Parameters:
$font - The font. If NULL, uses the current font.
$style - Font style. Possible values are (case insensitive):

The default value is regular.
$size - 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.

setFontSize()

public void setFontSize(int $size)

Defines the size of the current font.

See also: FPDF::setFont().
Parameters:
$size - The size (in points).


setKeywords()

public void setKeywords(UString $keywords)

Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
Parameters:
$keywords - The list of keywords.


setLeftMargin()

public void setLeftMargin(float $margin)

Defines the left margin. The method can be called before creating the first page.
Parameters:
$margin - The margin, user unit.


setLineWidth()

public void setLineWidth(float $width)

Defines the line width of borders and shapes. 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.

See also: FPDF::line(), FPDF::rect(), FPDF::cell(), FPDF::multiCell().
Parameters:
$width - The width.


setLink()

public void setLink(int $link, float $y = 0.0, int $page = -1)

Defines the page and position an internal link points to.
Parameters:
$link - The link identifier returned by FPDF::addLink().
$y - Ordinate of target position; -1 indicates the current position. The default value is 0 (top of page).
$page - Number of target page; -1 indicates the current page. This is the default value.


setMargins()

public void setMargins(float $left, float $top, float $right = 0.0)

Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them.

See also: FPDF::setLeftMargin(), FPDF::setTopMargin(), FPDF::setRightMargin(), FPDF::setAutoPageBreak().
Parameters:
$left - Left margin.
$top - Top margin.
$right - Right margin. Default value is the left one.


setPageFormat()

public void setPageFormat(string $format) throws InvalidArgumentException

Set page size by page format name. The value only affects the new added pages, not the current one.
Parameters:
$format - The page format name: A3, A4, A5, Letter, Legal. The value is case-insensitive.
Throws:
InvalidArgumentException - Invalid page format name.


setPageOrientation()

public void setPageOrientation(string $orientation) throws InvalidArgumentException

Sets page orientation. The value only affects the new added pages, not the current one.
Parameters:
$orientation - Default page orientation. Possible values are (case insensitive):


Throws:
InvalidArgumentException - Invalid orientation.

setPageSize()

public void setPageSize(float $a, float $b)

Set page size by width and height. Dimensions can be specified in any order. The value only affects the new added pages, not the curret one.

See also: FPDF::setPageFormat(), FPDF::setPageOrientation().
Parameters:
$a - First dimension of the page (user's units).
$b - Second dimension of the page (user's units).


setRightMargin()

public void setRightMargin(float $margin)

Defines the right margin. The method can be called before creating the first page.
Parameters:
$margin - The margin, user units.


setSubject()

public void setSubject(UString $subject)

Defines the subject of the document.
Parameters:
$subject - The subject.


setTextColor()

public void setTextColor(int $r, int $g, int $b)

Defines the color used for text. The method can be called before the first page is created and the value is retained from page to page.

See also: FPDF::setDrawColor(), FPDF::setFillColor(), FPDF::text(), FPDF::cell(), FPDF::multiCell().
Parameters:
$r - Red component (between 0 and 255).
$g - Green component (between 0 and 255).
$b - Blue component (between 0 and 255).


setTitle()

public void setTitle(UString $title)

Defines the title of the document.
Parameters:
$title - The title.


setTopMargin()

public void setTopMargin(float $margin)

Defines the top margin. The method can be called before creating the first page.
Parameters:
$margin - The margin, user units.


setUnit()

public void setUnit(string $unit)

Set the preferred user's unit for values passed to the methods of this class.
Parameters:
$unit - User unit. Possible values are:

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.

setX()

public void setX(float $x)

Defines the abscissa of the current position.

See also: FPDF::getX(), FPDF::getY(), FPDF::setY(), FPDF::setXY().
Parameters:
$x - The value of the abscissa. If negative, it is relative to the right of the page.


setXY()

public void setXY(float $x, float $y)

Defines the abscissa and ordinate of the current position.
Parameters:
$x - The value of the abscissa. If negative, it is relative to the right of the page.
$y - The value of the ordinate. If negative, it is relative to the bottom of the page.


setY()

public void setY(float $y)

Moves the current abscissa back to the left margin and sets the ordinate.

See also: FPDF::getX(), FPDF::getY(), FPDF::setX(), FPDF::setXY().
Parameters:
$y - The value of the ordinate. If negative, it is relative to the bottom of the page.


text()

public void text(float $x, float $y, UString $txt)

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.

See also: FPDF::setFont(), FPDF::setTextColor(), FPDF::cell(), FPDF::multiCell(), FPDF::write().
Parameters:
$x - Abscissa of the origin.
$y - Ordinate of the origin.
$txt - String to print.


widthOf()

public float widthOf(UString $s)

Returns the width of a string. A font must be selected.
Parameters:
$s - The string whose length is to be computed.
Return: Width of the string (user's units).


write()

public void write(float $h, UString $txt, mixed $link = NULL) throws ErrorException

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(FontCore::factory('helvetica', false, false),'',14);
	$pdf->write(5,u('Visit '));
	// Then put a blue underlined link
	$pdf->setTextColor(0,0,255);
	$pdf->setFont(NULL,'U');
	$pdf->write(5,u('www.fpdf.org'),'http://www.fpdf.org');

See also: FPDF::setFont(), FPDF::setTextColor(), FPDF::addLink(), FPDF::multiCell(), FPDF::setAutoPageBreak().
Parameters:
$h - Line height.
$txt - String to print.
$link - URL or identifier returned by FPDF::addLink().


Private constants: STATE_CLOSE, STATE_EMPTY, STATE_OPEN, STATE_PAGE

Private properties: $author, $buffer, $creator, $keywords, $links, $pageFields, $pageLinks, $pages, $subject, $title

Private methods: accountUsedChars(), beginPage(), doUnderline(), encodePageText(), encodeString(), endDoc(), endPage(), escape(), putAcroForm(), putCatalog(), putFields(), putInfo(), putPages(), putResourceDict(), putResources()
}

Private items

Private classes: org\fpdf\LinkArea, org\fpdf\LinkTarget, org\fpdf\Rect

Requirements

PHP Version: 7

Required modules: array, core, crypt, date, file, gd, iconv, locale, math, mbstring, networking, pcre, phpinfo, spl, standard, standard_reflection, streams, zlib

Required packages:

../../AutoloadException.php
../../CastException.php
../../InternalException.php
../../all.php
../../autoload.php
../../cast.php
../../errors.php
../../it/icosaedro/cast/ArrayBothType.php
../../it/icosaedro/cast/ArrayIntType.php
../../it/icosaedro/cast/ArrayStringType.php
../../it/icosaedro/cast/BooleanType.php
../../it/icosaedro/cast/ClassType.php
../../it/icosaedro/cast/FloatType.php
../../it/icosaedro/cast/IntType.php
../../it/icosaedro/cast/MixedType.php
../../it/icosaedro/cast/NullType.php
../../it/icosaedro/cast/ObjectType.php
../../it/icosaedro/cast/ResourceType.php
../../it/icosaedro/cast/StringType.php
../../it/icosaedro/cast/TypeInterface.php
../../it/icosaedro/cast/Types.php
../../it/icosaedro/containers/Comparable.php
../../it/icosaedro/containers/Equality.php
../../it/icosaedro/containers/Hash.php
../../it/icosaedro/containers/HashMap.php
../../it/icosaedro/containers/Hashable.php
../../it/icosaedro/containers/Printable.php
../../it/icosaedro/containers/Sortable.php
../../it/icosaedro/containers/UPrintable.php
../../it/icosaedro/io/CorruptedException.php
../../it/icosaedro/io/File.php
../../it/icosaedro/io/FileName.php
../../it/icosaedro/io/IOException.php
../../it/icosaedro/io/InputStream.php
../../it/icosaedro/io/PrematureEndException.php
../../it/icosaedro/io/SeekableInputStream.php
../../it/icosaedro/io/StringInputStream.php
../../it/icosaedro/io/codepage/CodePageInterface.php
../../it/icosaedro/io/codepage/GenericCodePage.php
../../it/icosaedro/io/codepage/UTF8CodePage.php
../../it/icosaedro/io/codepage/WindowsCodePage.php
../../it/icosaedro/utils/Codepoints.php
../../it/icosaedro/utils/Floats.php
../../it/icosaedro/utils/Integers.php
../../it/icosaedro/utils/StringBuffer.php
../../it/icosaedro/utils/Strings.php
../../it/icosaedro/utils/TestUnit.php
../../it/icosaedro/utils/UString.php
../../it/icosaedro/utils/UTF8.php
Field.php
Font.php
FontCore.php
Image.php
PdfObjWriterInterface.php

Generated by PHPLint Documentator