phptopdf et caracteres speciaux
Posté : 14 août 2008, 17:24
bonjour,
je comprend pas pourquoi mon pdf m'affiche des caractères bizzard à la place des accents.
voici un exemple
N° de pièce est affiché ---> N° de pièce
je vous laisse ci dessous mon script afin de vous donner une idée de ce que je veux faire.
je comprend pas pourquoi mon pdf m'affiche des caractères bizzard à la place des accents.
voici un exemple
N° de pièce est affiché ---> N° de pièce
je vous laisse ci dessous mon script afin de vous donner une idée de ce que je veux faire.
<?
include "".$_SERVER['DOCUMENT_ROOT']."/admin/include/mysql_connect.php";
$date = "2005-11-22";
$total = $_GET['total'];
if ($_GET['suite']<$total)
{
$debut_periode = date ( 'Y-m-d' , mktime ( 0,0,0, substr( $date , 5 , 2 ) ,substr( $date , 8 , 2 ) +$_GET['suite'] ,substr( $date , 0 , 4 )));
$debut_periode2 = strftime("%d/%m/%Y",strtotime($debut_periode));
$fin_periode = date ( 'Y-m-d' , mktime ( 0,0,0, substr( $date , 5 , 2 ) ,substr( $date , 8 , 2 ) +$_GET['suite']+1 ,substr( $date , 0 , 4 )));
include("phpToPDF.php");
$PDF=new phpToPDF();
$PDF->AddPage();
$PDF->SetTextColor(0, 0, 0);
$PDF->SetFont('Arial','B',8);
$PDF->Write(4, "INFONET CREATION\n\n");
$PDF->SetFont('Arial','B',13);
$PDF->Write(4, "Chiffre d'affaire pour la période du ".$debut_periode2." (en Euros)\n\n");
// Définition des propriétés du tableau.
$proprietesTableauA = array(
'TB_ALIGN' => 'R',
'L_MARGIN' => 1,
'BRD_COLOR' => array(0,0,0),
'BRD_SIZE' => '0.2',
);
// Définition des propriétés du header du tableau.
$proprieteHeaderA = array(
'T_COLOR' => array(0,0,0),
'T_SIZE' => 8,
'T_FONT' => 'Arial',
'T_ALIGN' => 'C',
'V_ALIGN' => 'M',
'T_TYPE' => 'B',
'LN_SIZE' => 5,
'BG_COLOR' => array(255, 255, 255),
'BRD_COLOR' => array(0,0,0),
'BRD_SIZE' => 0.2,
'BRD_TYPE' => '1',
'BRD_TYPE_NEW_PAGE' => '',
);
// Définition des propriétés du header du tableau.
$proprieteHeaderB = array(
'T_COLOR' => array(0,0,0),
'T_SIZE' => 8,
'T_FONT' => 'Arial',
'T_ALIGN' => 'C',
'V_ALIGN' => 'M',
'T_TYPE' => 'B',
'LN_SIZE' => 5,
'BG_COLOR' => array(216, 228, 232),
'BRD_COLOR' => array(0,0,0),
'BRD_SIZE' => 0.2,
'BRD_TYPE' => '1',
'BRD_TYPE_NEW_PAGE' => '',
);
// Contenu du header du tableau.
$contenuHeaderA = array(25, 25, 65, 25, 25, 25, "[CB]Date écriture", "[CB]N° de pièce", "[CB]Libellé de l'écriture", "[CB]Montant débit", "[CB]Montant crédit", "[CB]Solde cumulé");
// Définition des propriétés du reste du contenu du tableau.
$proprieteContenuA = array(
'T_COLOR' => array(0,0,0),
'T_SIZE' => 8,
'T_FONT' => 'Arial',
'T_ALIGN_COL0' => 'C',
'T_ALIGN' => 'C',
'V_ALIGN' => 'M',
'T_TYPE' => '',
'LN_SIZE' => 5,
'BG_COLOR' => array(255, 255, 255),
'BRD_COLOR' => array(0,0,0),
'BRD_SIZE' => 0.1,
'BRD_TYPE' => '1',
'BRD_TYPE_NEW_PAGE' => '',
);
$sql25 = "SELECT DATE_FORMAT(date,'%d/%m/%Y') as date,num_paie,description,type,id FROM paiement WHERE date>='$debut_periode' AND date<'$fin_periode'";
$req25 = mysql_query($sql25) or die('Erreur SQL !<br>'.$sql25.'<br>'.mysql_error());
$i = 1;
$debut_solde = 0;
while($data25 = mysql_fetch_array($req25))
{
$sql10 = mysql_query("SELECT montant FROM paiement WHERE id='".$data25['id']."'") or die (mysql_error());
list($montant) = mysql_fetch_row($sql10);
if ($data25['type']=='credit')
{
$credit_aff = "".sprintf('%.2f', $montant)."";
$debit_aff = '0.00';
}
if ($data25['type']=='debit')
{
$debit_aff = "".sprintf('%.2f', $montant)."";
$credit_aff = '0.00';
}
$solde = $debut_solde+$credit_aff-$debit_aff;
if ($montant=='')
{
$tarif = '0.00';
}
else
{
$tarif = "".sprintf('%.2f', $montant)."";
}
$tarif_nul = "0.00";
if ($$i<10)
{
$aff_id = "000".$i."";
}
elseif ($i>=10 AND $i<100)
{
$aff_id = "00".$i."";
}
$contenuTableauA1 .= "".$data25['date']."\n";
$contenuTableauA2 .= "".$data25['num_paie']."\n";
$contenuTableauA3 .= "[L]".$data25['description']."\n";
$contenuTableauA4 .= "[R]".$debit_aff."\n";
$contenuTableauA5 .= "[R]".$credit_aff."\n";
$contenuTableauA6 .= "[R]".sprintf('%.2f', $solde)."\n";
$i++;
$debut_solde = $solde;
}
$contenuA = array($contenuTableauA1,$contenuTableauA2,$contenuTableauA3,$contenuTableauA4,$contenuTableauA5,$contenuTableauA6);
$PDF->drawTableau($PDF, $proprietesTableauA, $proprieteHeaderB, $contenuHeaderA, $proprieteContenuA, $contenuA);
$sql20 = mysql_query("SELECT SUM(montant) FROM paiement WHERE type='debit' AND date>='".$debut_periode."' AND date<='".$fin_periode."'") or die (mysql_error());
list($total_debit) = mysql_fetch_row($sql20);
$sql30 = mysql_query("SELECT SUM(montant) FROM paiement WHERE type='credit' AND date>='".$debut_periode."' AND date<='".$fin_periode."'") or die (mysql_error());
list($total_credit) = mysql_fetch_row($sql30);
$total_cumule = $total_credit-$total_debit;
// Contenu du header du tableau.
$contenuHeaderB = array(25, 25, 25, "[CB]Total débit", "[CB]Total crédit", "[CB]Total cumulé");
$contenuB = array("[R]".sprintf('%.2f', $total_debit)."", "[R]".sprintf('%.2f', $total_credit)."", "[R]".sprintf('%.2f', $total_cumule)."");
$PDF->drawTableau($PDF, $proprietesTableauA, $proprieteHeaderB, $contenuHeaderB, $proprieteContenuA, $contenuB);
$PDF->Output("CA_".$debut_periode.".pdf", "F");
$type = "text/pdf";
$type2 = "text/pdf";
$name_file = "CA_".$debut_periode.".pdf";
//----------------------------------
// Construction de l'entête
//----------------------------------
$boundary = "-----=".md5(uniqid(rand()));
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$header .= "\r\n";
$msg = "Bonjour,\n\nVeuillez trouver le fichier récapitulant votre chiffre d'affaire pour la journée du ".$debut_periode2." en pièce joite.\r\n";
$msg .= "--$boundary\r\n";
$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding:8bit\r\n";
$msg .= "\r\n";
$msg .= "Bonjour,\n\nVeuillez trouver le fichier récapitulant votre chiffre d'affaire pour la journée du ".$debut_periode2." en pièce joite.";
$msg .= "\r\n";
$file = $name_file;
$fp = fopen($file, "rb");
$attachment = fread($fp, filesize($file));
fclose($fp);
$attachment = chunk_split(base64_encode($attachment));
$msg .= "--$boundary\r\n";
$msg .= "Content-Type: $type2; name=\"$file\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "Content-Disposition: inline; filename=\"$file\"\r\n";
$msg .= "\r\n";
$msg .= $attachment . "\r\n";
$msg .= "\r\n\r\n";
$msg .= "--$boundary--\r\n";
$mail_client = "".$email."";
$mail_admin = "[email protected]";
$expediteur = "[email protected]";
$reponse = $expediteur;
$sujet_client = "Votre CA pour la journée du ".$debut_periode2."";
$sujet_admin = "Votre CA pour la journée du ".$debut_periode2."";
mail($mail_admin, $sujet_admin, $msg, "Reply-to: $reponse\r\nFrom: $expediteur\r\n".$header);
$suite2 = $_GET['suite']+1;
header('location: test3.php?suite='.$suite2.'&total='.$total.'');
}
if ($_GET['suite']==$total)
{
echo "Script terminé";
}
?>