Add-On MultiCell with bullet
Informations
Author: Patrick BennyLicense: FPDF
Description
This method allows to output a MultiCell with a bullet in front of the first line. Text is indented to the right of the bullet.Usage is the same as MultiCell except that there's an extra $blt parameter for the text of the bullet.
MultiCellBlt(float w, float h, string blt, string txt [, mixed border [, string align [, boolean fill]]])
Source
<?php
require('fpdf.php');
class PDF extends FPDF
{
//MultiCell with bullet
function MultiCellBlt($w, $h, $blt, $txt, $border=0, $align='J', $fill=false)
{
//Get bullet width including margins
$blt_width = $this->GetStringWidth($blt)+$this->cMargin*2;
//Save x
$bak_x = $this->x;
//Output bullet
$this->Cell($blt_width, $h, $blt, 0, '', $fill);
//Output text
$this->MultiCell($w-$blt_width, $h, $txt, $border, $align, $fill);
//Restore x
$this->x = $bak_x;
}
}
?>
Example
<?php
require('MultiCellBlt.php');
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Times', '', 12);
$column_width = ($pdf->GetPageWidth()-30)/2;
$sample_text = 'This is bulleted text. The text is indented and the bullet appears at the first line only.';
for ($n=1; $n<=3; $n++)
$pdf->MultiCellBlt($column_width, 6, chr(149), $sample_text.' '.$sample_text);
for ($n=1; $n<=2; $n++)
$pdf->MultiCellBlt($column_width, 6, '>', $sample_text.' '.$sample_text);
$pdf->SetXY($column_width+10*2, 10);
for ($n=1; $n<=10; $n++)
$pdf->MultiCellBlt($column_width, 6, "$n)", $sample_text);
$pdf->Output();
?>