CakePHP 3 and FPDF

FPDF is a PHP class which allows to generate PDF files with pure PHP. which can be easily integrated in our CakePHP 3 app.

Install FPDF via composer:

php composer.phar require setasign/fpdf

Add this at the top of our controller file:

use Setasign\Fpdf;
Create a test PDF in one of your actions:
$pdf = new \FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
exit;

Leave a Reply

Your email address will not be published. Required fields are marked *