Imports a TrueType, OpenType or Type1 font and makes it available. It is necessary to generate a font definition file.
Step : 1
First download your custom font and file must be in ttf format. place the font in your project directory.Step : 2
add php path (C:\xampp\php) in your PC
This Pc -> Properties -> Advanced system settings -> Environment Variables -> Path (double Click) ->add php path -> press Ok
Step : 3
Open Command Prompt -> follow the command in this below image
cmd Code
C:\Users\Tutor Joes>cd\ C:\>cd xampp C:\xampp>cd htdocs C:\xampp\htdocs>cd FPDF_CONTENT C:\xampp\htdocs\FPDF_CONTENT>cd customFont C:\xampp\htdocs\FPDF_CONTENT\customFont>dir Volume in drive C has no label. Volume Serial Number is B8EC-E7FE Directory of C:\xampp\htdocs\FPDF_CONTENT\customFont 24-12-2022 16:19 <DIR> . 24-12-2022 16:19 <DIR> .. 09-01-2013 00:00 168,260 Roboto.ttf 1 File(s) 168,260 bytes 2 Dir(s) 155,286,028,288 bytes free C:\xampp\htdocs\FPDF_CONTENT\customFont>php C:\xampp\htdocs\FPDF_CONTENT\fpdf\makefont\makefont.php Roboto.ttf PHP Warning: Module 'openssl' already loaded in Unknown on line 0 Warning: Module 'openssl' already loaded in Unknown on line 0 Font file compressed: Roboto.z Font definition file generated: Roboto.php
Step : 4
Copy the font zip file.
Step : 5
Place the copy files in fpdf font location.
<?php require_once "fpdf/fpdf.php"; //fpdf supporting file //Page Creation (Default value is P;Default value is mm;default page size: A4) # $pdf = new FPDF(); //or $pdf = new FPDF('P','mm','A4'); $pdf -> AddPage(); // SetFont(family,style,size) $pdf -> SetFont('Arial','',14); //Using bold,italic,underline the text $pdf -> SetFont('Arial','BIU',14); //B-bold; I-italic; U-underline //addFont(family,style,file) $pdf ->addFont('Roboto','','Roboto.php'); //Adding Custom Font $pdf -> SetFont('Roboto','',10); $pdf -> Output(); // Display output ?>View Demo
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions