Creation fichier pdf

flopad Messages postés 528 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 mars 2009 - 15 févr. 2006 à 16:22
flopad Messages postés 528 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 mars 2009 - 15 févr. 2006 à 16:49
Hello,

j'exporte ma base access en un fichier pdf grace au code suivant, j'aimerais pouvoir préciser la largeur que doit faire chaque colonne.

Comment faire????

<?php


if (isset ($_POST['submit']) && $_POST['submit'] === 'Valider') {



$base="D:\\Qualite\Annuaire\Annuaire.mdb";
$Annuaire="Annuaire";


//connection au serveur:
$cnx = odbc_connect( "DSN_Annuaire","" ,"") or die ("Impossible de se connecter à la base de donnée") ;

//PDF


define('FPDF_FONTPATH','font/');
require('fpdf/fpdf.php');


$pdf=new FPDF('L','cm','A4');

$pdf->SetFont('Arial','B',12);
$pdf->AddPage();
$pdf->SetFillColor(220,130,130);
$pdf->SetTextColor(255,255,255);

//Titres des colonnes
$header=array('Nom - Prénom','Site','N° Téléphone fixe','N° fax','N° Portable','Adresse e-mail');

$pdf->cell(4.7,1,$header[0],1,0,'C',1);// Le nom dans tous les cas


for($i=0;$i<count($_POST['choix']);$i++)
{
if(isset($_POST['choix'][$i]))
$pdf->cell(4.7,1,$header[$i+1],1,0,'C',1);// les autres postes si cases cochées
}

if (isset($_POST['choix'])){
$addInQuery = implode(',', $_POST['choix']);
$addInQuery = ','.$addInQuery;
}
else $addInQuery = '';

$resultat = odbc_exec( $cnx, 'SELECT Nom'.$addInQuery.' FROM Annuaire ORDER BY Nom');




$pdf->SetFillColor(0xdd,0xdd,0xdd);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY(1,$pdf->GetY()+1);
$fond=0;
while( $row = odbc_fetch_array( $resultat ) ) //tant que c pas la fin de la table
{
$pdf->cell(4.7,0.7,$row['Nom'],1,0,'C',$fond);
if(isset($_POST['choix'][0]))
$pdf->cell(4.7,0.7,$row['Societe'],1,0,'C',$fond);
if(isset($_POST['choix'][1]))
$pdf->cell(4.7,0.7,$row['Fixe'],1,0,'C',$fond);
if(isset($_POST['choix'][2]))
$pdf->cell(4.7,0.7,$row['Fax'],1,0,'C',$fond);
if(isset($_POST['choix'][3]))
$pdf->cell(4.7,0.7,$row['Portable'],1,0,'C',$fond);
if(isset($_POST['choix'][4]))
$pdf->cell(4.7,0.7,$row['Mail'],1,0,'C',$fond);

$pdf->SetXY(1,$pdf->GetY()+0.7);
$fond=!$fond;
}
$pdf->output();

}


?>
<html>
<head>
</head>


<form action="ann.php" method="POST">


Site

N° téléphone fixe

N° fax

N° portable

Adresse e-mail


</form>

</html>

2 réponses

sidf Messages postés 1216 Date d'inscription mardi 20 décembre 2005 Statut Membre Dernière intervention 18 octobre 2012 5
15 févr. 2006 à 16:33
regarde les scripts sur cette page, ça m'a bien rendu servicehttp://www.phpinfo.net/articles/article_sylk.html
0
flopad Messages postés 528 Date d'inscription mercredi 28 septembre 2005 Statut Membre Dernière intervention 6 mars 2009
15 févr. 2006 à 16:49
J'ai essayé de suivre, mais ca me donne une erreur ; mon code est :   

Site N° téléphone fixe N° fax N° portable Adresse e-mail

ERREUR :Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 427Notice: Array to string conversion in D:\qualite\fpdf\fpdf.php on line 679Warning: Cannot modify header information - headers already sent by (output started at D:\qualite\fpdf\fpdf.php:427) in D:\qualite\fpdf\fpdf.php on line 1022FPDF error: Some data has already been output to browser, can't send PDF file
0
Rejoignez-nous