Erreur lors de la génération de pdf avec la classe fpdf
Fermé
ananias8686
Messages postés
86
Date d'inscription
samedi 9 février 2019
Statut
Membre
Dernière intervention
19 août 2023
-
Modifié le 9 oct. 2021 à 06:20
ananias8686 Messages postés 86 Date d'inscription samedi 9 février 2019 Statut Membre Dernière intervention 19 août 2023 - 10 oct. 2021 à 15:13
ananias8686 Messages postés 86 Date d'inscription samedi 9 février 2019 Statut Membre Dernière intervention 19 août 2023 - 10 oct. 2021 à 15:13
A voir également:
- Pdf_mc_table
- Erreur 0x80070643 - Guide
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Comment réduire la taille d'un pdf - Guide
- Comment faire un pdf - Guide
- Comment modifier un pdf - Guide
2 réponses
jordane45
Messages postés
38201
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
5 juin 2024
4 675
9 oct. 2021 à 09:20
9 oct. 2021 à 09:20
Bonjour
Deplace ton include avant le début de ta class ou sinon mets le dans une fonction . Mais en tout cas tu ne peux pas le laisser là..
Deplace ton include avant le début de ta class ou sinon mets le dans une fonction . Mais en tout cas tu ne peux pas le laisser là..
ananias8686
Messages postés
86
Date d'inscription
samedi 9 février 2019
Statut
Membre
Dernière intervention
19 août 2023
9 oct. 2021 à 09:43
9 oct. 2021 à 09:43
Je vous remercie pour votre suggestion, J ai fais sortir l include vers le haut mais ça fais de même, apparemment la classe refuse toute mes variables
Je me demande si je dois mettre tout le corps de la classe dans une fonction puisque j ai fermer sa balise a la dernière ligne. Je vais essayer et vous faire un retour
PHP Parse error: syntax error, unexpected '$link' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) in /home/site/public_html/fpdf/a/ex2.php on line 7
Je me demande si je dois mettre tout le corps de la classe dans une fonction puisque j ai fermer sa balise a la dernière ligne. Je vais essayer et vous faire un retour
jordane45
Messages postés
38201
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
5 juin 2024
4 675
Modifié le 9 oct. 2021 à 09:58
Modifié le 9 oct. 2021 à 09:58
Par ce que dans une class .. il s'attend à avoir des méthodes ...
class truc{ private $variable = "toto"; // une variable pour ta class par exemple public function foo{ // ici le code de ce que doit faire ta fonction echo $this->variable; // affiche le contenu de ta variable } }
ananias8686
Messages postés
86
Date d'inscription
samedi 9 février 2019
Statut
Membre
Dernière intervention
19 août 2023
>
jordane45
Messages postés
38201
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
5 juin 2024
9 oct. 2021 à 23:06
9 oct. 2021 à 23:06
Voici mon nouveau code qui fonctionne parfaitement sauf que la disposition des données n est pas bien faite.
<?php require('mysql_table.php'); class PDF extends PDF_MySQL_Table { protected $ProcessingTable=false; protected $aCols=array(); protected $TableX; protected $HeaderColor; protected $RowColors; protected $ColorIndex; function Header() { // Print the table header if necessary //if($this->ProcessingTable) // $this->TableHeader(); // Title $this->SetFont('Arial','',14); // Logo $this->Image('logo.png',160,15,30); // Saut de ligne $this->Ln(10); $this->y0 = $this->GetY(); // Ensure table header is printed parent::Header(); } function TableHeader() { $this->SetFont('Arial','B',12); $this->SetX($this->TableX); $fill=!empty($this->HeaderColor); if($fill) $this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]); foreach($this->aCols as $col) $this->Cell($col['w'],6,$col['c'],1,0,'C',$fill); $this->Ln(); } function Row($data) { $this->SetX($this->TableX); $ci=$this->ColorIndex; $fill=!empty($this->RowColors[$ci]); if($fill) $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); foreach($this->aCols as $col) $this->Cell($col['w'],5,$data[$col['f']],1,0,$col['a'],$fill); $this->Ln(); $this->ColorIndex=1-$ci; } function CalcWidths($width, $align) { // Compute the widths of the columns $TableWidth=0; foreach($this->aCols as $i=>$col) { $w=$col['w']; if($w==-1) $w=$width/count($this->aCols); elseif(substr($w,-1)=='%') $w=$w/100*$width; $this->aCols[$i]['w']=$w; $TableWidth+=$w; } // Compute the abscissa of the table if($align=='C') $this->TableX=max(($this->w-$TableWidth)/2,0); elseif($align=='R') $this->TableX=max($this->w-$this->rMargin-$TableWidth,0); else $this->TableX=$this->lMargin; } function AddCol($field=-1, $width=-1, $caption='', $align='L') { // Add a column to the table if($field==-1) $field=count($this->aCols); $this->aCols[]=array('f'=>$field,'c'=>$caption,'w'=>$width,'a'=>$align); } function Table($link, $query, $prop=array()) { // Execute query $res=mysqli_query($link,$query) or die('Error: '.mysqli_error($link)."<br>Query: $query"); // Add all columns if none was specified if(count($this->aCols)==0) { $nb=mysqli_num_fields($res); for($i=0;$i<$nb;$i++) $this->AddCol(); } // Retrieve column names when not specified foreach($this->aCols as $i=>$col) { if($col['c']=='') { if(is_string($col['f'])) $this->aCols[$i]['c']=ucfirst($col['f']); else $this->aCols[$i]['c']=ucfirst(mysqli_fetch_field_direct($res,$col['f'])->name); } } // Handle properties if(!isset($prop['width'])) $prop['width']=0; if($prop['width']==0) $prop['width']=$this->w-$this->lMargin-$this->rMargin; if(!isset($prop['align'])) $prop['align']='C'; if(!isset($prop['padding'])) $prop['padding']=$this->cMargin; $cMargin=$this->cMargin; $this->cMargin=$prop['padding']; if(!isset($prop['HeaderColor'])) $prop['HeaderColor']=array(); $this->HeaderColor=$prop['HeaderColor']; if(!isset($prop['color1'])) $prop['color1']=array(); if(!isset($prop['color2'])) $prop['color2']=array(); $this->RowColors=array($prop['color1'],$prop['color2']); // Compute column widths $this->CalcWidths($prop['width'],$prop['align']); // Print header $this->TableHeader(); // Print rows $this->SetFont('Arial','',11); $this->ColorIndex=0; $this->ProcessingTable=true; while($row=mysqli_fetch_array($res)) $this->Row($row); $this->ProcessingTable=false; $this->cMargin=$cMargin; $this->aCols=array(); } } // Connect to database $link = mysqli_connect('localhost','test','test_','test'); $pdf = new PDF(); $pdf->AddPage(); // First table: output all columns $pdf->Table($link,'SELECT date,details,sender,content,amount,check_status FROM int_transfer WHERE user_id = 142 UNION SELECT date,details,sender,content,amount,check_status FROM tran_acct WHERE user_id = 142 UNION SELECT date,details,sender,content,amount,check_status FROM int_transfer_admin WHERE user_id = 142 ORDER BY date DESC'); $pdf->AddPage(); // Second table: specify 3 columns $pdf->AddCol('date',25,'','C'); $pdf->AddCol('details',20,'Type'); $pdf->AddCol('sender',30,'Beneficiary','R'); $pdf->AddCol('content',60,'Details ','C'); $pdf->AddCol('amount',20,'Amount'); $pdf->AddCol('check_status',30,'Status','C'); $prop = array('HeaderColor'=>array(255,150,100), 'color1'=>array(210,245,255), 'color2'=>array(255,255,210), 'padding'=>2); $pdf->Table($link,'SELECT date,details,sender,content,amount,check_status FROM int_transfer WHERE user_id = 142 UNION SELECT date,details,sender,content,amount,check_status FROM tran_acct WHERE user_id = 142 UNION SELECT date,details,sender,content,amount,check_status FROM int_transfer_admin WHERE user_id = 142 ORDER BY date DESC',$prop); $pdf->Output(); ?>
ananias8686
Messages postés
86
Date d'inscription
samedi 9 février 2019
Statut
Membre
Dernière intervention
19 août 2023
>
jordane45
Messages postés
38201
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
5 juin 2024
10 oct. 2021 à 15:13
10 oct. 2021 à 15:13
Bonjour
Svp Comment utiliser la méthode MultiCell pour régler la disposition des données dans mon tableau.
Svp Comment utiliser la méthode MultiCell pour régler la disposition des données dans mon tableau.