This repository is clone of fpdf.org with typed variables, enumerations and PHP 8.2 dependencies.
PdfDocument
is a PHP class, which allows to generate PDF files with pure PHP.
F from FPDF2 stands for Free: you may use it for any kind of usage and
modify it to suit your needs.
If you're using Composer to manage dependencies, you can use:
composer require laurentmuller/fpdf2
Alternatively, you can add the requirement "laurentmuller/fpdf2":"^2.0"
to
your composer.json
file and run composer update
. This could be useful when
the installation of FPDF2 is not compatible with some currently installed
dependencies. Anyway, the previous option is the preferred way, since composer
can pick the best requirement constraint for you.
use fpdf\Enums\PdfFontName;
use fpdf\Enums\PdfFontStyle;
use fpdf\PdfDocument;
$pdf = new PdfDocument();
$pdf->addPage();
$pdf->setFont(PdfFontName::ARIAL, PdfFontStyle::BOLD, 16);
$pdf->cell(40, 10, 'Hello World!');
$pdf->output();