Shadow Cell

Informations

Author: Gledston Reis
License: FPDF

Description

This extension allows to add a shadow effect to the text contained in a cell. The ShadowCell() method has the same parameters as Cell(), plus the following ones:

color : color of the shadow. Can be either a string (G for grey, B for black) or an integer between 0 and 255 (greyscale value). Default value: G.

distance : distance between the shadow and the text. Default value: 0.5.

Source

<?php
require('fpdf.php');

class PDF_Shadow extends FPDF
{
    function ShadowCell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $color='G', $distance=0.5)
    {
        if($color=='G')
            $ShadowColor = 100;
        elseif($color=='B')
            $ShadowColor = 0;
        else
            $ShadowColor = $color;
        $TextColor = $this->TextColor;
        $x = $this->x;
        $this->SetTextColor($ShadowColor);
        $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link);
        $this->TextColor = $TextColor;
        $this->x = $x;
        $this->y += $distance;
        $this->Cell($w, $h, $txt, 0, $ln, $align);
    }
}
?>

Example

<?php
require('shadow.php');

$pdf = new PDF_Shadow();
$pdf->SetFont('Arial','',30);

$pdf->AddPage();    
$pdf->SetTextColor(255,  255, 255);
for ($i = 1; $i < 6; $i++) {
    $Text = sprintf('Gray shadow with %.1F distance', $i / 2);
    $pdf->ShadowCell(0, 40, $Text, 1, 1, 'C', true, '', 'G', $i / 2);
    $pdf->Ln(10);
}

$pdf->AddPage();    
$pdf->SetTextColor(0, 0, 255);
for ($i = 1; $i < 6; $i++) {
    $Text = sprintf('Black shadow with %.1F distance', $i / 2);
    $pdf->ShadowCell(0, 40, $Text, 1, 1, 'C', false, '', 'B', $i / 2);
    $pdf->Ln(10);
}

$pdf->Output();
?>
View the result here.

Download

ZIP | TGZ