IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[FPDF] Affichage entête de colonne après saut de page


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre régulier
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Juin 2007
    Messages
    179
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 66
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2007
    Messages : 179
    Points : 97
    Points
    97
    Par défaut [FPDF] Affichage entête de colonne après saut de page
    bonjour,
    voici mon code qui fonctionne trés bien,
    les données proviennent d'un fichier texte
    mon problème c'est la deuxiéme page qui s'affiche correctement avec le tableau, ces données mais pas les entêtes de colonne ????
    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
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
     
    <?
    define('FPDF_FONTPATH','../../font/');
    require('../../fpdf.php');
     
    class PDF extends FPDF
    {
     
    //Chargement des données
    function LoadData($file)
    {
        //Lecture des lignes du fichier
        $lines=file($file);
        $data=array();
        foreach($lines as $line)
            $data[]=explode(';',chop($line));
        return $data;
    }
     
    //En-tête  de page 
    function Header()
    {
     
        //Police Arial gras 15
        $this->SetFont('Arial','B',15);
        //Décalage à droite
        $this->Cell(50);
        //Titre
        $this->Cell(20,10,"S.E.P.A ".date('Y')." (s.a.r.l)     Importation des données le : ".date('d/m/Y')."  à  ".date('H:i:s')." ",0,'C');
        //Saut de ligne
        $this->Ln(20);
        // en tetet tableau si necessaire
        parent::Header();
    }
     
    //Pied de page
    function Footer()
    {
        //Positionnement à 1,5 cm du bas
        $this->SetY(-15);
        //Police Arial italique 8
        $this->SetFont('Arial','I',8);
        //Numéro de page
        $this->Cell(0,10,'Page '.$this->PageNo().'',0,0,'C');
    }
     
    //renvoye le nombre de ligne d'un MultiCell prend en parametres une largeur et un texte
    function NbLines($w,$txt){
    //Computes the number of lines a MultiCell of width w will take
    $cw=&$this->CurrentFont['cw'];
    if($w==0)
    $w=$this->w-$this->rMargin-$this->x;
    $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
    $s=str_replace("\r",'',$txt);
    $nb=strlen($s);
    if($nb>0 and $s[$nb-1]=="\n")
    $nb--;
    $sep=-1;
    $i=$j=$l=0;
    $nl=1;
    while($i<$nb){
    $c=$s[$i];
    if($c=="\n"){
    $i++;
    $sep=-1;
    $j=$i;
    $l=0;
    $nl++;
    continue;
    }
    if($c==' ')
    $sep=$i;
    $l+=$cw[$c];
    if($l>$wmax){
    if($sep==-1){
    if($i==$j)
    $i++;
    }
    else
    $i=$sep+1;
    $sep=-1;
    $j=$i;
    $l=0;
    $nl++;
    }
    else
    $i++;
    }
    return $nl;
    }
     
    function CheckPageBreak($h){
    //Si la hauteur h provoque un débordement, saut de page manuel
    if($this->GetY()+$h>$this->PageBreakTrigger)
    $this->AddPage($this->CurOrientation);
    }
     
    //Tableau coloré
    function lectdonne($header,$data){
    //Couleurs, épaisseur du trait et police grasse
    $this->SetFillColor(128,128,128);
    $this->SetTextColor(255,255,255);
    $this->SetDrawColor(0,0,0);
    $this->SetLineWidth(.1);
    $this->SetFont('','B');
    //En-tête
    $w = array('15','20','15','10','15','10','10','15','8','8','10','10','15','10','45','45');
    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);
    $this->SetTextColor(0);
    $this->SetFont('');
    //Données
    $fill=0;
     
    $x_base = $this->GetX();
     
    foreach($data as $row){
    unset($nb_ligne);
     
    $nb_ligne[] .= $this->NbLines($w[0],$row[0]);//
    $nb_ligne[] .= $this->NbLines($w[1],$row[1]);
    $nb_ligne[] .= $this->NbLines($w[2],$row[2]);
    $nb_ligne[] .= $this->NbLines($w[3],$row[3]);
    $nb_ligne[] .= $this->NbLines($w[4],$row[4]);
    $nb_ligne[] .= $this->NbLines($w[5],$row[5]);
    $nb_ligne[] .= $this->NbLines($w[6],$row[6]);//
    $nb_ligne[] .= $this->NbLines($w[7],$row[7]);
    $nb_ligne[] .= $this->NbLines($w[8],$row[8]);
    $nb_ligne[] .= $this->NbLines($w[9],$row[9]);
    $nb_ligne[] .= $this->NbLines($w[10],$row[10]);
    $nb_ligne[] .= $this->NbLines($w[11],$row[11]);
    $nb_ligne[] .= $this->NbLines($w[12],$row[12]);//
    $nb_ligne[] .= $this->NbLines($w[13],$row[13]);
    $nb_ligne[] .= $this->NbLines($w[14],$row[14]);
    $nb_ligne[] .= $this->NbLines($w[15],$row[15]);
     
     
    $nb_ligne_max = max($nb_ligne);
     
    $hauteur = 16 * $nb_ligne_max;
     
    //Effectue un saut de page si nécessaire
    $this->CheckPageBreak($hauteur);
     
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[0];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[0],6,$row[0].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[0]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[1];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[1],6,$row[1].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[1]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[2];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[2],6,$row[2].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[2]),($y));
     
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[3];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[3],6,$row[3].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[3]),($y));
     
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[4];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[4],6,$row[4].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[4]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[5];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[5],6,$row[5].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[5]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[6];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[6],6,$row[6].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[6]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[7];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[7],6,$row[7].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[7]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[8];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[8],6,$row[8].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[8]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[9];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[9],6,$row[9].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[9]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[10];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[10],6,$row[10].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[10]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[11];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[11],6,$row[11].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[11]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[12];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[12],6,$row[12].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[12]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[13];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[13],6,$row[13].$bckn,'LRBT','C',$fill);
    $this->SetXY(($x+$w[13]),($y));
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[14];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[14],6,$row[14].$bckn,'LRBT','L',$fill);
    $this->SetXY(($x+$w[14]),($y));
     
     
    $x = $this->GetX();
    $y = $this->GetY();
    $nb_bckn = $nb_ligne_max - $nb_ligne[15];
    $bckn ='';
    for($i=0;$i <= $nb_bckn;$i++)
    $bckn .= "\n";
     
    $this->MultiCell($w[15],6,$row[15].$bckn,'LRBT','L',$fill);
    $this->SetXY($x_base,($y + (6 * $nb_ligne_max)));
     
    $fill=!$fill;
    }
    //Trait de terminaison
    $this->Cell(array_sum($w),0,'','T');
    }
    }
    $pdf=new PDF('L','mm','A4');
    $pdf->Open();
     
    //Chargement des données
    $data=$pdf->LoadData('import.txt');
    $pdf->SetFont('Arial','',6);
    $pdf->SetAutoPageBreak(True,4);
    $pdf->AddPage();
    //Titres des colonnes
    $header=array('Date','Client','Type','Stock','Chassis','Pneus','Couleur','Clé','Porte','Km','Version','Série','Cde','Radio','R.G','Notes');
    $pdf->lectdonne($header,$data);
    $pdf->Output();
    ?>

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    60
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 60
    Points : 65
    Points
    65
    Par défaut
    Je n'ai peut-être pas bien compris le problème mais je me demande, pourquoi ne pas utiliser phpToPDF tout simplement ? phpToPDF gère ça sans soucis.

  3. #3
    Membre régulier
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Juin 2007
    Messages
    179
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 66
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2007
    Messages : 179
    Points : 97
    Points
    97
    Par défaut re infos
    bonjour,
    je reprend ce site c'est pourquoi je le dépanne. Mais s'il ny a pas d'autres soluce
    je changerais

    merci

Discussions similaires

  1. Problème multicols, saut de colonne et saut de page
    Par Celadon dans le forum Mise en forme
    Réponses: 2
    Dernier message: 05/10/2010, 11h51
  2. Réponses: 11
    Dernier message: 04/06/2008, 10h10
  3. Figure en pleine page sur 2 colonnes sans saut de page
    Par djubuntu dans le forum Tableaux - Graphiques - Images - Flottants
    Réponses: 2
    Dernier message: 30/05/2008, 12h02
  4. Affichage d'une colonne après migration
    Par fefe44 dans le forum Ruby on Rails
    Réponses: 3
    Dernier message: 04/03/2008, 19h56
  5. Réponses: 3
    Dernier message: 28/10/2007, 23h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo