comment généré un fichier pdf en php
<?php require_once('eng.php'); require_once('tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 061'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // set font $pdf->SetFont('helvetica', '', 10); // add a page $pdf->AddPage(); //$html = file_get_contents('http://localhost/frenchLessonsWebsite/main/phpInvoiceGenerator.php'); //$html = file_get_contents('phpInvoiceGenerator.php'); ob_start(); include('phpInvoiceGenerator.php'); $html = ob_* ob_get_contents(); ob_end_clean(); // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); //Close, output and save PDF document $pdf->Output('example_061.pdf', 'I'); $pdf->Output('../invoices/example.pdf', 'F'); $pdf->Table('select * from consultation'); $pdf->AddPage(); $pdf->Output(); ?>
EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici :ICI Merci d'y penser dans tes prochains messages. |
$pdf->Table('select * from consultation');
$pdf->writeHTML($html, true, false, true, false, '');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans titre</title> </head> <body bgcolor="#000"> <?php include('../script/variable.php'); $link=mysql_connect('localhost','root',''); if(!$link) { die('<p> Impossible de se connecter :'.mysql_error().'</p>'); } $db=mysql_select_db('gestionpatients',$link); if(!$db) { die('<p> Impossible d\'utiliser la base : '.mysql_error().'</p>'); } echo("<table border=1 bgcolor=#fff bordercolor=#99CCFF align='center' height=100%> <td>"); $sqlquery1="select id_patient from patient"; $queryresult1=mysql_query($sqlquery1); while($row=mysql_fetch_array($queryresult1,MYSQL_ASSOC)) $id_patient=$row['id_patient']; $sqlquery1="select nom,prenom,id_patient,sexe from patient where id_patient=$id_patient"; $queryresult1=mysql_query($sqlquery1); while($row=mysql_fetch_array($queryresult1,MYSQL_ASSOC)) echo"ID : <font face=Georgia, Times New Roman, Times, serif color=#000>".$row['id_patient']."<br/> Nom : ".$row['nom']."<br/> Prenoms : ".$row['prenom']."<br/> Sexe : ".$row['sexe']."</font><br/> "; $sqlquery1="select id_patient from patient"; $queryresult1=mysql_query($sqlquery1); while($row=mysql_fetch_array($queryresult1,MYSQL_ASSOC)) $id_patient=$row['id_patient']; $sqlquery2="select domaine,date,mont,login from consultation where id_patient=$id_patient"; $queryresult2=mysql_query($sqlquery2); while($row1=mysql_fetch_array($queryresult2,MYSQL_ASSOC)) echo"Type de consultation : <font face=Georgia, Times New Roman, Times, serif color=#000 >".$row1['domaine']."<br/> Date :".$row1['date']."<br/> Montant :<strong> ".$row1['mont']." F CFA</strong><br/> Nom de la caissière : ".$row1['login']."</font><br/> <center><font face=Georgia, Times New Roman, Times, serif color=#000 size=-2><i>Le centre hospitalier regional de man vous remercie et vous souhaite prompt rétablisssement !!! <br/> $datet</i></font></center> <hr><i> Contact : 22-30-06-10 / 22-21-10-11</i></td> "; echo("</table>"); include('../script/for.php'); ?> </body> </html>
<?php require('mysql_table.php'); require_once('eng.php'); require_once('tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 061'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // set font $pdf->SetFont('helvetica', '', 10); // add a page $pdf->AddPage(); //$html = file_get_contents('http://localhost/frenchLessonsWebsite/main/phpInvoiceGenerator.php'); //$html = file_get_contents('phpInvoiceGenerator.php'); ob_start(); include('phpInvoiceGenerator.php'); $html = ob_* ob_get_contents(); ob_end_clean(); // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); //Close, output and save PDF document $pdf->Output('patient1.pdf', 'I'); $pdf->Output('patient1.pdf', 'F'); ?>