j'utilise depuis pas mal de temps HTML2PDF est j'en suis très satisfait
toutefois je bloque sur une nouvelle génération de pdf
j'ai une requête sql qui me récupère différents champ dans une base de donnée sql server
elle me retourne en moyenne 1600 lignes (18 colonnes)
a partir de la je génère un tableau html classique
mon problème est que la génération de ce tableau est exécrablement lente (5 à 10minutes)
j'aurais aimé savoir si cela était normal au vue de ce que j'ai a afficher ou si cela provenez d'une mauvaise programmation de ma par
HTML2PDF : v4.03
Apache 2.2.14
PHP 5.3.1
ci-joint le code de ma page ainsi que le debug
merci d'avance
<?php
set_time_limit(100000);
ini_set('memory_limit','512M');
//ini_set("display_errors",0);
// get the HTML
ob_start();
?>
<style type="text/css">
<!--
#corp td{text-align:left;font-size:9px;border-bottom:1px dashed #333333 ;padding:2px;}
#corp th{text-align:left;font-size:12px;border-bottom:1px dashed #333333 ;padding:2px}
#corp{height:90%;}
.separcolhard{border-left:2px dashed black ;font-size:8px;}
.separcolsoft{border-left:1px dashed #333333 ;font-size:8px;}
table.page_footer{width: 100%; border: none; border-top: solid 1mm black; padding: 2mm}
.etab{height:70;font-size:25;font-weight:bold;}
.livnum{height:100;font-size:;font-weight:bold;text-align:right;}
.periode{height:50;font-size:;font-weight:bold;}
.au{height:50;font-size:;font-weight:bold;}
.registre{height:150;font-size:35;font-weight:bold;text-align:center;}
.vehoccas{height:150;font-size:55;font-weight:bold;text-align:center;}
.entresortie{height:150;font-size:45;font-weight:bold;text-align:center;}
.visa{height:150;font-size:;font-weight:bold;}
.reduc{width:800;}
.norm{width:220;}
p{margin:10;}
.basdepage{width: 100%; text-align: right;}
.corp td{font-size:8px;}
.stock{width:40px;}
.type{width:40px;}
.annee{width:40px;}
.immat{width:60px;}
.firstimmat{width:70px;}
.km{width:70px;}
.marque{width:70px;}
.modele{width:160px;}
.couleur{width:70px;}
.vin{width:80px;}
.dateachat{width:60px;}
.prixachat{width:60px;}
.client{width:80px;}
.fourn{width:80px;}
.datevente{width:60px;}
.vendeur{width:80px;}
.prixvente{width:60px;}
.newimmat{width:60px;}
-->
</style>
<page backtop="10mm" backbottom="14mm" backleft="15mm" backright="10mm" style="font-size: 12pt">
<table ID='firstpage'>
<tr>
<td class='etab norm'>ETABLISSEMENT</td>
<td class='etab reduc'></td>
<td class='etab norm'></td>
<td class='etab norm'></td>
</tr>
<tr>
<td class='livnum norm' style='border:solid 1px black'></td>
<td class='livnum reduc'>LIVRE N°..................................</td>
<td class='periode norm'>PERIODE...................................</td>
<td class='au norm'>AU........................................</td>
</tr>
<tr>
<td class='registre' colspan=4>REGISTRE DE POLICE D'OBJETS MOBILIERS</td>
</tr>
<tr>
<td class='vehoccas' colspan=4>VEHICULES D'OCCASION</td>
</tr>
<tr>
<td class='entresortie' colspan=4>ENTREE & SORTIE</td>
</tr>
<tr>
<td class='visa norm'></td>
<td class='visa reduc'></td>
<td class='visa norm' colspan=2>
<p>visa de l'autorité</p>
<p>Le présent registre ........................................... feuillets</p>
<p>a été coté et paraphé par nous, .....................................</p>
<p>...........................................................................................</p>
<p>...........................................................................................</p>
<p>...........................................................................................</p>
<p></p>
<p>A............................................., le ......................................</p>
</td>
</tr>
</table>
</page>
<?php
$annee=$_POST['annee'];
$emp = $_POST['societe'];
/*
$annee='2013';
$emp = 001;
*/
$requete="****";
//echo $requete;
$base='***';
$dbcon = mssql_connect(***','***','***');
mssql_select_db($base);
$result=mssql_query($requete,$dbcon);
echo "<page pageset='old' pagegroup='new' backcolor='white' font-size:'9px' style='font: arial;'>";
echo '<page_footer>
<table class="page_footer">
<tr>
<td class="basdepage">
page [[page_cu]]/[[page_nb]]
</td>
</tr>
</table>
</page_footer>';
echo "<table id='corp'>
<thead>
<tr style='border-bottom:2px dashed #333333 ;'>
<th colspan=10>informations véhicules</th>
<th class='separcolhard' colspan=4>informations achats</th>
<th class='separcolsoft' colspan=4>informations ventes</th>
</tr>
<tr style='border-bottom:2px dashed #333333 ;'>
<th class='separcolsoft stock'>N°stock</th>
<th class='separcolsoft type'>type</th>
<th class='separcolsoft annee'>année</th>
<th class='separcolsoft immat'>immat</th>
<th class='separcolsoft firstimmat'>1ere immat</th>
<th class='separcolsoft km'>Km</th>
<th class='separcolsoft marque'>marque</th>
<th class='separcolsoft modele'>modele</th>
<th class='separcolsoft couleur'>couleur</th>
<th class='separcolsoft vin'>vin</th>
<th class='separcolhard dateachat'>date achat</th>
<th class='separcolsoft prixachat'>prix achat</th>
<th class='separcolsoft client'>client</th>
<th class='separcolsoft fourn'>fourn</th>
<th class='separcolhard datevente'>date vente</th>
<th class='separcolsoft vendeur'>vendeur</th>
<th class='separcolsoft prixvente'>prix vente</th>
<th class='separcolsoft newimmat'>IMMAT</th>
</tr></thead>";
while($row = mssql_fetch_assoc($result))
{
echo "<tr>
<td class='separcolsoft stock'>".aff($row['numstock'])."</td>
<td class='separcolsoft type'>".aff(substr($row['vin'],3,6))."</td>
<td class='separcolsoft annee'>".aff($row['AnoModelo'])."</td>
<td class='separcolsoft immat'>".aff($row['Matric'])."</td>
<td class='separcolsoft firstimmat'>".aff($row['firstimmat'])."</td>
<td class='separcolsoft km'>".aff($row['Km'])."</td>
<td class='separcolsoft marque'>".aff($row['marque'])."</td>
<td class='separcolsoft modele'>".reduc(aff($row['modele']))."</td>
<td class='separcolsoft couleur'>".strtolower(aff($row['couleur']))."</td>
<td class='separcolsoft vin'>".aff($row['vin'])."</td>
<td class='separcolhard dateachat'>".aff($row['dateachat'])."</td>
<td class='separcolsoft prixachat'>".aff($row['prixachat'])."</td>
<td class='separcolsoft client'>".aff($row['client'])."</td>
<td class='separcolsoft fourn'>".aff($row['fourn'])."</td>
<td class='separcolhard datevente'>".aff($row['datevente'])."</td>
<td class='separcolsoft vendeur'>".aff($row['vendeur'])."</td>
<td class='separcolsoft prixvente'>".aff($row['prixvente'])."</td>
<td class='separcolsoft newimmat'>".aff($row['newIMMAT'])."</td>
</tr>";
}
echo "</table></page>";
function aff($value)
{
if(empty($value))
{return '.';}
else
{return htmlentities($value);}
}
function reduc($value)
{
$pos = strpos($value,'(');
if($pos>1)
{
return substr($value, 0,$pos);
}else{
return $value;
}
}
$content = ob_get_clean();
// convert
require_once('../../include/module/html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('L', 'A3', 'fr', true, 'UTF-8', 0);
//$html2pdf->setModeDebug();
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output('livre2police.pdf');
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
?>debug :
step time delta memory peak
Init debug 0.0 ms 0.0 ms 12 027.1 Ko 15 770.2 Ko
PAGE 1 Begin 10 393.7 ms 10 393.7 ms 63 672.3 Ko 105 449.4 Ko
Table n1 Begin 10 401.5 ms 7.8 ms 63 775.2 Ko 105 449.4 Ko
Table 1 End 10 607.4 ms 205.9 ms 63 954.9 Ko 105 449.4 Ko
PAGE 1 End 10 607.8 ms 0.3 ms 63 952.0 Ko 105 449.4 Ko
PAGE 2 Begin 10 607.8 ms 0.1 ms 63 952.0 Ko 105 449.4 Ko
Table n2 Begin 10 624.9 ms 17.1 ms 64 011.9 Ko 105 449.4 Ko
Table 2 End 10 636.8 ms 11.9 ms 63 968.2 Ko 105 449.4 Ko
Table n3 Begin 10 638.1 ms 1.3 ms 63 972.8 Ko 105 449.4 Ko
Table n2 Begin 113 098.1 ms102 460.0 ms 90 527.1 Ko 105 449.4 Ko
Table 2 End 113 109.7 ms 11.6 ms 90 522.2 Ko 105 449.4 Ko
Table n2 Begin 126 400.6 ms 13 290.9 ms 92 439.2 Ko 105 449.4 Ko
Table 2 End 126 411.8 ms 11.2 ms 92 415.8 Ko 105 449.4 Ko
Table n2 Begin 139 294.5 ms 12 882.7 ms 94 227.3 Ko 105 449.4 Ko
Table 2 End 139 306.4 ms 11.9 ms 94 203.7 Ko 105 449.4 Ko
Table n2 Begin 154 130.3 ms 14 824.0 ms 96 089.1 Ko 105 449.4 Ko
Table 2 End 154 141.5 ms 11.1 ms 96 064.5 Ko 105 449.4 Ko
Table n2 Begin 172 826.8 ms 18 685.4 ms 97 825.3 Ko 105 449.4 Ko
Table 2 End 172 838.0 ms 11.1 ms 97 802.7 Ko 105 449.4 Ko
Table n2 Begin 187 476.4 ms 14 638.5 ms 99 592.8 Ko 105 449.4 Ko
Table 2 End 187 487.7 ms 11.3 ms 99 569.6 Ko 105 449.4 Ko
Table n2 Begin 200 209.4 ms 12 721.7 ms 101 515.6 Ko 105 449.4 Ko
Table 2 End 200 220.6 ms 11.1 ms 101 492.0 Ko 105 449.4 Ko
Table n2 Begin 216 066.7 ms 15 846.2 ms 103 241.1 Ko 106 360.0 Ko
Table 2 End 216 077.9 ms 11.1 ms 103 217.4 Ko 106 360.0 Ko
Table n2 Begin 230 194.0 ms 14 116.2 ms 105 026.5 Ko 108 075.8 Ko
Table 2 End 230 205.1 ms 11.1 ms 105 003.1 Ko 108 075.8 Ko
Table n2 Begin 243 725.0 ms 13 519.8 ms 106 992.2 Ko 109 991.2 Ko
Table 2 End 243 736.1 ms 11.1 ms 106 968.5 Ko 109 991.2 Ko
Table n2 Begin 257 372.1 ms 13 636.0 ms 108 951.1 Ko 112 040.5 Ko
Table 2 End 257 383.2 ms 11.1 ms 108 928.5 Ko 112 040.5 Ko
Table n2 Begin 270 170.3 ms 12 787.1 ms 110 906.4 Ko 113 957.0 Ko
Table 2 End 270 181.4 ms 11.1 ms 110 883.9 Ko 113 957.0 Ko
Table n2 Begin 285 013.5 ms 14 832.0 ms 113 254.0 Ko 116 358.1 Ko
Table 2 End 285 024.6 ms 11.2 ms 113 231.4 Ko 116 358.1 Ko
Table n2 Begin 301 042.4 ms 16 017.8 ms 115 171.4 Ko 118 268.5 Ko
Table 2 End 301 053.5 ms 11.1 ms 115 147.7 Ko 118 268.5 Ko
Table n2 Begin 315 430.9 ms 14 377.3 ms 117 092.7 Ko 120 196.3 Ko
Table 2 End 315 442.0 ms 11.1 ms 117 069.3 Ko 120 196.3 Ko
Table n2 Begin 329 294.7 ms 13 852.7 ms 118 980.8 Ko 122 113.4 Ko
Table 2 End 329 305.9 ms 11.2 ms 118 957.2 Ko 122 113.4 Ko
Table n2 Begin 344 600.1 ms 15 294.2 ms 120 775.1 Ko 123 899.2 Ko
Table 2 End 344 611.2 ms 11.1 ms 120 751.2 Ko 123 899.2 Ko
Table n2 Begin 363 253.9 ms 18 642.8 ms 122 589.0 Ko 125 703.5 Ko
Table 2 End 363 265.0 ms 11.1 ms 122 564.9 Ko 125 703.5 Ko
Table n2 Begin 376 413.0 ms 13 147.9 ms 124 472.2 Ko 127 465.2 Ko
Table 2 End 376 424.0 ms 11.1 ms 124 448.7 Ko 127 465.2 Ko
Table n2 Begin 389 578.2 ms 13 154.2 ms 126 357.6 Ko 129 425.7 Ko
Table 2 End 389 589.3 ms 11.0 ms 126 334.4 Ko 129 425.7 Ko
Table 3 End 399 572.9 ms 9 983.6 ms 128 139.5 Ko 131 176.6 Ko
PAGE 22 End 399 573.2 ms 0.3 ms 128 139.4 Ko 131 176.6 Ko
Before output 399 687.2 ms 114.0 ms 103 183.8 Ko 131 176.6 Ko