Project

General

Profile

Fpdf Multicell (Advanced) User Manual

Overview

In order to create a PDF Advanced Multicell the following steps are required:

  • have a valid Pdf object
  • create the advanced multicell object
  • add the multicells to the Pdf

Create the PDF object

Please refer to the fpdf class manual in order to get this done correctly.

// create new PDF document
$oPdf = new FPDF();
$oPdf->Open();
$oPdf->SetMargins(20, 20, 20);

//set default font/colors
$oPdf->SetFont('arial', '', 11);
$oPdf->SetTextColor(200, 10, 10);
$oPdf->SetFillColor(254, 255, 245);

//add the page
$oPdf->AddPage();
$oPdf->AliasNbPages();

Create the Advanced Multicell object

Just call the advanced table constructor and pass the Pdf Object as a parameter to the constructor.

/**
 * Create the Advanced Multicell Object and pass the PDF object as a parameter to the constructor
 */
$oMulticell = new PdfMulticell($oPdf);

Set the tag styles

Specify the styles that will be used in the multicell

/**
* Set the styles
*/
$oMulticell->setStyle("p", "times", "", 11, "130,0,30");
$oMulticell->setStyle("b", "times", "B", 11, "80,80,260");
$oMulticell->setStyle("i", "times", "I", 11, "80,80,260");
$oMulticell->setStyle("u", "times", "U", 11, "80,80,260");
$oMulticell->setStyle("h1", "arial", "", 14, "80,80,260");
$oMulticell->setStyle("h2", "times", "B", 13, "203,0,48");
$oMulticell->setStyle("h3", "times", "B", 12, "203,0,48");
$oMulticell->setStyle("h4", "arial", "BI", 11, "0,151,200");
$oMulticell->setStyle("style", "times", "B", 11, "255,189,12");

Text Formatting

No formatting

The default PDF formatting is used in this case

//no formatting
$s = "This is a simple text";
$oMulticell->multiCell(0, 5, $s);

Simple formatting

//simple formatting
$s = "<pp>This is a paragraph</pp>";

$oMulticell->multiCell(0, 5, $s);

Nested tags

In case of nested tags, the styles are NOT inherited

$s = "<pp>This is <b>BOLD</b> text, this is <i>ITALIC</i></pp>";

$oMulticell->multiCell(0, 5, $s);

Subscripts and superscripts

Subscript and superscripts can be adjusted with the ypos attribute. See example:

$s = "<pp ypos='-0.8'>Subscript</pp> or <pp ypos='1.1'>Superscript</pp>";

$oMulticell->multiCell(0, 5, $s);

Links

You can create links by using the href attribute in a tag.


$s = "<pp>Created by <h1 href='mailto:andy@interpid.eu'>Andrei Bintintan</h1>
<h1 href='www.interpid.eu'>www.interpid.eu</h1></pp>";

$oMulticell->multiCell(0, 5, $s);

Paragraphs

Paragraphs can be created by using the size attribute and the ~~~ reserved pattern for paragraphs. See the following example:

$s = "<size size='50' >Paragraph Example:~~~</size><font> - Paragraph 1</font>
<pp size='60' > ~~~</pp><font> - Paragraph 2</font>
<pp size='60' > ~~~</pp> - Paragraph 2
<pp size='70' >Sample text~~~</pp><pp> - Paragraph 3</pp>
<pp size='50' >Sample text~~~</pp> - Paragraph 1
<pp size='60' > ~~~</pp><h4> - Paragraph 2</h4>" 

$oMulticell->multiCell(0, 5, $s);