PHP 7 FPDF Example: Add TrueType Fonts inside PDF Document

index.php

<?php
define('FPDF_FONTPATH','./');

require('fpdf/fpdf.php');

$pdf=new FPDF();

// Add new font from the calligra.php file
$pdf->AddFont('Calligrapher','','calligra.php');

//Add a new page
$pdf->AddPage();

// Set the font for the text
$pdf->SetFont('Calligrapher','',35);

// Prints a cell with given text
$pdf->Cell(60,20,'Hello GeeksforGeeks!');

// Set the font for the text
$pdf->SetFont('Calligrapher','',72);

// Prints a cell with given text
$pdf->Cell(60,60,'Its fun');

// return the generated output
$pdf->Output();
?>

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.