Nous allons voir aujourd’hui comment intégrer la très utile library FPDF dans le framework CodeIgniter. Tout d’abord, il faut télécharger le package de FPDF à l’adresse suivante http://www.fpdf.org/ dans lq rubrique « Télécharger ».
Ensuite il suffit de copier le fichier fpdf.php dans le dossier /application/libraries/ et le dossier « font » dans le dossier /system/fonts
Ajouter la ligne de code ci-dessous dans le fichier /application/config/config.php
$config['fonts_path']= "le-chemin-de-votre dossier-font"; |
Pour tester, la library créer un contrôleur pdf.php avec le code suivant:
$this->load->library('fpdf'); define('FPDF_FONTPATH',$this->config->item('fonts_path')); $this->fpdf->Open(); $this->fpdf->AddPage(); $this->fpdf->SetFont('Arial','',12); $this->fpdf->Cell(20,10,'Hello World!'); $this->fpdf->Output(); |
Mots-clefs :CodeIgniter, FPDF, PDF, PHP



hello, i have a dude
what is « le-chemin-de-votre dossier-font »?
this is rigth -> $config['fonts_path']= « http://localhost/ci/system/fonts/ »;
i`m confused, please help me.
It’s not the URL path but the folder path /system/fonts/
Hello
I am very interested in using PDF with Codeigniter, therefore I try to test what is said on this page. I have followed exactly the above procedure but when I test the sample I get the two following messages :
A PHP Error was encountered
Severity : warning
Message: include(helvetica.php) [function.include]: failed to open strean: No such file or directory
Filename: libraries/fpdf.php
Line Number : 1147
A PHP Error was encountered
Severity : warning
Message: include() [function.include]: Failed opening ‘helvetica.php’ for inclusion (include_path=’.;C\php5\pear’)
Filename: libraries/fpdf.php
Line Number : 1147
I do not understand why helvetica is called since the sample uses Arial, also why is pear mentioned.
Many thanks to whoever can help me.
Alain
What is your CodeIgniter version?