Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.17 KB

tuto_7.md

File metadata and controls

48 lines (38 loc) · 1.17 KB

Transparency

Since version 2.0.3, transparency can be added within the PdfDocument.

Note: The code is inspired from this given FPDF script created by Martin Hall-May.

To use it, create a derived class and use the PdfTransparencyTrait trait:

use fpdf\Enum\PdfBlendMode;
use fpdf\PdfDocument;
use fpdf\Traits\PdfTransparencyTrait;

class TransparencyDocument extends PdfDocument
{
    use PdfTransparencyTrait;
}

// instanciation of inherited class
$pdf = new TransparencyDocument();
// output an image with no transparency
$pdf->image('logo.png', 10, 20);
// set alpha with a 50% of transparency
$pdf->setAlpha(0.5, PdfBlendMode::NORMAL);
// output an image with transparency
$pdf->image('logo.png', 50, 20);
// restore alpha to default
$pdf->resetAlpha();

Result:

Result

See also: