1. Go to this page and download the library: Download setasign/setafpdf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
setasign / setafpdf example snippets
$loader = new \Example\Psr4AutoloaderClass;
$loader->register();
$loader->addNamespace('setasign\SetaFpdf', 'path/to/src');
use \setasign\SetaFpdf\SetaFpdf;
;
$pdf->AddFont('DejaVuSans', '', '/path/to/DejaVuSans.ttf');
$pdf->SetFont('DejaVuSans', '', 20);
$pdf->Write(20, 'Love & Ζω!'); // Write in UTF-8
$pdf->Output();
class Pdf extends FPDF
{
public function Footer()
{
$this->SetY(-15);
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'R');
}
}
$pdf = new Pdf();
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
$pdf->Output();
class Pdf extends SetaFpdf
{
public function writeFooters()
{
$this->SetAutoPageBreak(false);
$pageCount = $this->getPageCount();
// iterate through the pages and draw the footer
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$this->SetPage($pageNo);
$this->SetY(-15);
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/' . $pageCount, 0, 0, 'R');
}
$this->SetAutoPageBreak(true);
}
}
$pdf = new Pdf();
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
$pdf->AddPage();
// ...
// write the footers
$pdf->writeFooters();
// ...
$pdf->Output();