Bonjour à tous,
je dois créer un PDF avec la classe FPDF à partir d'une BDD.

Pour le moment j'utilise la fonction Cell, ça fonctionne mais lorsque mon texte est long, il dépasse sur les autres cellules, j'ai vu que la fonction MultiCell permet de faire des retours à la ligne.
Le soucis étant que je n'arrive pas DU TOUT à appliquer le MultiCell avec mon code... je sais que le sujet a déjà été traité mais je n'y arrive vraiment pas et ça commence un peu à être fatiguant..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
require('connexion.php');
require ('fpdf.php');
 
class PDF extends FPDF
{
var $col = 0;
var $y0;
function header (){
 
// Logo
    $this->Image('logo.png',10,6,30);
// Police Arial gras 15
    $this->SetFont('Arial','B',15);
    // Décalage à droite
    $this->Cell(95);
    // Titre
    $this->Cell(10,20,'Récapitulatif des prestations','C');
    // Saut de ligne
    $this->Ln(20);
}
function Footer()
{
    // Pied de page
    $this->SetY(-15);
    $this->SetFont('Arial','I',8);
    $this->SetTextColor(128);
    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
function SetCol($col)
{
    // Positionnement sur une colonne
    $this->col = $col;
    $x = 10+$col*65;
    $this->SetLeftMargin($x);
    $this->SetX($x);
}
 
function AcceptPageBreak()
{
    // Méthode autorisant ou non le saut de page automatique
    if($this->col<2)
    {
        // Passage à la colonne suivante
        $this->SetCol($this->col+1);
        // Ordonnée en haut
        $this->SetY($this->y0);
        // On reste sur la page
        return false;
    }
    else
    {
        // Retour en première colonne
        $this->SetCol(0);
        // Saut de page
        return true;
    }
}
function Tableau($header,$data)
{
    //Couleurs, épaisseur du trait et police BOLD
    $this->SetFillColor(150,180,255); //fond des entetes de colonnes
    $this->SetTextColor(0); //couleur du texte des entetes des colonnes
    $this->SetDrawColor(0); // couleur des bordures
    $this->SetLineWidth(.2); //epaisseur des traits
    $this->SetFont('','B');
 
    //En-tête
    $w=array(7,30,50,15,15,25,30,7,15,15,15,15,16,16,20);
    for($i=0;$i<count($header);$i++)
        $this->Cell($w[$i],7,$header[$i],1,0,'C',1);
    $this->Ln();
 
    //Restauration des couleurs et de la police
    $this->SetFillColor(224,235,255); //couleur du fond des cases
    $this->SetTextColor(0); //couleur du texte des cases
    $this->SetFont('');
 
    //Données
    $fill=true;
    foreach($data as $row)
    {
        $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
        $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
        $this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
        $this->Cell($w[3],6,$row[3],'LR',0,'L',$fill);
    	  $this->Cell($w[4],6,$row[4],'LR',0,'L',$fill);
   	  $this->Cell($w[5],6,$row[5],'LR',0,'L',$fill);  
    	  $this->Cell($w[6],6,$row[6],'LR',0,'L',$fill);
        $this->Cell($w[7],6,$row[7],'LR',0,'L',$fill);
        $this->Cell($w[8],6,$row[8],'LR',0,'L',$fill);
        $this->Cell($w[9],6,$row[9],'LR',0,'L',$fill);  
        $this->Cell($w[10],6,$row[10],'LR',0,'L',$fill);
        $this->Cell($w[11],6,$row[11],'LR',0,'L',$fill);
        $this->Cell($w[12],6,$row[12],'LR',0,'L',$fill);
        $this->Cell($w[13],6,$row[13],'LR',0,'L',$fill);
        $this->Cell($w[14],6,$row[14],'LR',0,'L',$fill);  
    	  $this->Ln();
        $fill=!$fill;
    }
 
    $this->Cell(array_sum($w),0,'','T');
}
}
 
 
$data = array();
 
//Requete SQL, pour la classe imprimer on change le format DATE_TIME vers DATE avec 'CAST'
$sql = $pdo->query ('SELECT event_id, event_titre, event_description, CAST( event_debut AS DATE ), CAST(event_finTH as DATE), event_nomclient, event_lieu, event_type, event_ref, event_numero, event_commercial, CAST(event_dateDtransp as DATE), event_nbembauche, event_nbcuisinier, event_heureArrivee FROM table_evenements');
//Boucle sur les resultats
while($col = $sql->fetch())
{
    array($col);
    $data[] = $col;  
}
 
$sql->closeCursor();
 
//Creation nouveau pdf L = Paysage, P = Portrait
$pdf=new PDF('L');
//Titres des colonnes
$header=array('Id','Titre','Description','Début','Fin Th.','Client','Lieu','Type','Ref.','Numéro','Commercial','Transp Deb','NB Serveur','Nb Cuisinier','Arrivée');
$pdf->SetFont('Arial','',7);
$titre = 'Recapitulatif Prestation';
$pdf->SetTitle($titre);
$pdf->SetMargins(2,30);
$pdf->AddPage();
$pdf->Tableau($header,$data);
$pdf->Output('Recapitulatif_Prestations_'.date("Y_m_d").'.pdf','I');
?>
Je voudrais donc remplacer les Cell par du MultiCell.
Je vous remercie d'avance, et soyez indulgents, je suis un grand débutant !