Open polinevol opened 1 year ago
Hi, I'm trying to print a multipage pdf using a while loop but the final pdf doesn't render...just a html render ! Her my code
<?php /** * Html2Pdf Library - example * * HTML => PDF converter * distributed under the OSL-3.0 License * * @package Html2pdf * @author Laurent MINGUET <webmaster@html2pdf.fr> * @copyright 2023 Laurent MINGUET */ //require_once dirname(__FILE__).'/../vendor/autoload.php'; require_once dirname(__FILE__).'/../../vendor/autoload.php'; use Spipu\Html2Pdf\Html2Pdf; use Spipu\Html2Pdf\Exception\Html2PdfException; use Spipu\Html2Pdf\Exception\ExceptionFormatter; try { ob_start(); include dirname(__FILE__).'/res/rpt_journal_caisse.php'; $content = ob_get_clean(); $html2pdf = new Html2Pdf('P', 'A4', 'fr'); $html2pdf->setDefaultFont('Arial'); $html2pdf->writeHTML($content); $html2pdf->output('example00.pdf'); } catch (Html2PdfException $e) { $html2pdf->clean(); $formatter = new ExceptionFormatter($e); echo $formatter->getHtmlMessage(); }``` and for the data side ` <?php require('maconnexion2.php'); $jrouvre = "-1"; if (isset($_GET['jrouvre'])) { $jrouvre= $_GET['jrouvre']; } $user_id = "-1"; if (isset($_GET['userid'])) { $user_id = $_GET['userid']; } $jr_ouvre = strtotime($jrouvre); $dj = date('Y-m-d',$jr_ouvre); $query_caissiers = "SELECT DISTINCT v.user_validation_caisse_id, u.civilite, u.nom, u.prenom FROM vue_ventes_par_jour v INNER JOIN users u on v. user_validation_caisse_id = u.id WHERE date_vente = '".$dj."'"; $req_caissiers = mysqli_query($maconnexion, $query_caissiers) or die(mysqli_error($maconnexion)); //echo $query_caissiers; //tableau caissiers while($caissier = mysqli_fetch_array($req_caissiers)){ $query_jcr = "SELECT * from vue_ventes_par_jour WHERE date_format(date_vente, '%Y-%m-%d')= '".$dj."' and user_validation_caisse_id = ".$caissier['user_validation_caisse_id']; $req_jcr = mysqli_query($maconnexion, $query_jcr) or die(mysqli_error($maconnexion)); while($row = mysqli_fetch_array($req_jcr)){ $datevente = $row['date_vente']; }; //echo $query_jcr; //Totaux ventes par type paiement $query_totaux = "SELECT type_paiement, sum(total_vente) as total_vente from vue_ventes_par_jour WHERE date_vente = '".$dj."' and user_validation_caisse_id = ".$caissier['user_validation_caisse_id']." group by type_paiement"; $req_totaux = mysqli_query($maconnexion, $query_totaux) or die(mysqli_error($maconnexion)); //echo $query_totaux; //total ventes $query_tv = "SELECT v.date_vente, sum(v.mt_remise) as mt_remise, sum(v.total_vente) as total_ventes from vue_ventes_par_jour v WHERE date_vente = '".$dj."' and user_validation_caisse_id = ".$caissier['user_validation_caisse_id']." group by v.date_vente"; $req_tv = mysqli_query($maconnexion, $query_tv) or die(mysqli_error($maconnexion)); while($row = mysqli_fetch_array($req_tv)){ $totalventes = $row['total_ventes']; $mtremise = $row['mt_remise']; }; ?> <page style="font-size: 8pt; font-family: Arial;"> <table align="center" style="margin-top:20px;font-weight:bold; font-size: 12pt; "> <tr> <td> MA COMPAGNIE<br> </td> </tr> </table> <br> <table align="center" style="font-weight:bold;border:solid 1px #000; text-align:center;padding:2px 20px;line-height:1.5;"> <tr> <td>Header text</td> </tr> </table> <br> <table align="center" bgcolor="#eaea00" style="border:solid 1px #000; font-size:18px;font-weight:bold;padding:2px 97px;"> <tr> <td>Journal de caisse du <?= $jrouvre;?></td> </tr> </table> <br> <table align="center" cellspacing="0"> <tr> <td style="border-top:solid 1px #000;border-bottom:solid 1px #000;font-weight:bold; font-size:18px;padding-right:250px;">Total ventes</td> <td style="border-top:solid 1px #000;border-bottom:solid 1px #000;font-weight:bold; font-size:18px;padding-left:38px;"><?= $totalventes;?></td> </tr> </table> </page> <?php } ?> `
Hi, I'm trying to print a multipage pdf using a while loop but the final pdf doesn't render...just a html render ! Her my code