1

Bonjour,

Je suis en train d'essayer d'utiliser html2pdf pour créer à la volée des rapports en pdf, à partir de html. Cel marche franchement bien avec un tableau de quelques lignes, mais dés que j'ajoute des lignes (environ 70), j'obtiens une page blanche et rien dans les logs d'erreur php.
Avec xdebug activé, xdebug bloque le processus en indiquant que la limite de "nested functions" est atteinte. J'ai monté le niveau de fonction imbriquées à 2500, et maintenant j'ai une page blanche. J'ai aussi monté la mémoire affectée à php à 128Mb sans effet visible.
Le code html est le suivant :
<link type="text/css" href="http://localhost/Mhb/components/com_mhbstats/css/print.css" rel="stylesheet" >
<page backtop="10mm" backbottom="10mm">
  <page_header>
    <table style="width: 100%; border-bottom: solid 1px black;">
      <tr>
        <td style="text-align: left;  width: 33%">html2pdf</td>
        <td style="text-align: center;  width: 34%">Test d'header</td>
        <td style="text-align: right; width: 33%">07/04/2009</td>

      </tr>
    </table>
  </page_header>
  <page_footer>
    <table style="width: 100%; border-top: solid 1px black;">
      <tr>
        <td style="text-align: left;  width: 50%">html2pdf.fr</td>
        <td style="text-align: right; width: 50%">page [[page_cu]]/[[page_nb]]</td>

      </tr>
    </table>
  </page_footer>
  
<div class="print_header">
<h1> Rapport de statistiques</h1>
</div>
<table class="print_body">
	<thead>
		<tr>
					<th style="width:20%">Activité			</th>

						<th style="width:5%">Jan			</th>
						<th style="width:5%">Fév			</th>
						<th style="width:5%">Mar			</th>
						<th style="width:5%">Avr			</th>
						<th style="width:5%">Mai			</th>
						<th style="width:5%">Juin			</th>

						<th style="width:5%">Juil			</th>
						<th style="width:5%">Août			</th>
						<th style="width:5%">Sep			</th>
						<th style="width:5%">Oct			</th>
						<th style="width:5%">Nov			</th>
						<th style="width:5%">Déc			</th>

						<th style="width:8%">Total			</th>
						<th style="width:6%">2008			</th>
						<th style="width:6%">%			</th>
					</tr>
	</thead>
	<tfoot>
		<tr>

			<td align="center" colspan="16">Fin de la table</td>
		</tr>
	</tfoot>
	<tbody>
			<tr>
			<td>Catégorie 1</td>
						<td align="center">10</td>

						<td align="center">20</td>
						<td align="center">30</td>
						<td align="center">40</td>
						<td align="center">50</td>
						<td align="center">60</td>
						<td align="center">70</td>

						<td align="center">80</td>
						<td align="center">90</td>
						<td align="center">100</td>
						<td align="center">110</td>
						<td align="center">120</td>
						<td align="center">780</td>

			<td align="center">700</td>
			<td align="center">1.1</td>
		</tr>
				<tr>
			<td>Catégorie 2</td>
						<td align="center">20</td>
						<td align="center">20</td>

						<td align="center">30</td>
						<td align="center">40</td>
						<td align="center">50</td>
						<td align="center">60</td>
						<td align="center">70</td>
						<td align="center">80</td>

						<td align="center">90</td>
						<td align="center">200</td>
						<td align="center">220</td>
						<td align="center">220</td>
						<td align="center">780</td>
			<td align="center">700</td>

			<td align="center">1.1</td>
		</tr>

Ensuite les tr se répètent, jusqu'à la fin de la page; où il ya :
</tbody>
</table>
</page>

Jusqu'à une cinquantaine de ligne, ça à l'air d'aller, plus loin, ça coince...

Quelqu'un at-il une suggestion ?

Par avance merci

2

Complément d'information : il semble que le problème se produise quand on dépasse une page. Je peux ajouter des lignes, et le document est créé tant que l'on reste sur la même page. Dès qu'il faut passer à la suivante, page blanche. Je crois que html2pdf gère tout seule ces sauts de page, non ?

3

normalement oui, les sauts de page sont gérés automatiquement.

peut-etre est-ce du aux thead et tfoot dont je n'ai rajouté la gestion que tres recemment.

essaye sans les thead et tfoot pour voir si ca marche
Ancien pseudo : lolo

4

BINGO!

Bien joué, ça marche. En fait, je n'ai supprimé que tfoot, pour voir, et ça a suffit!
Bravo et merci pour cette librairie, bien plus rapide et complète que tcpdf smile

5

bon, ben je vais vérifier de mon côté ce qui fait planter le tfoot
Ancien pseudo : lolo

6

il me faudrait ta feuille de style pour que je fasse des tests, tu pourrais la mettre ici ?
Ancien pseudo : lolo

7

Bonjour,
Je n'ai presque rien dans la feuille de style, j'en suis au début !

div.print_header {
  width: 100%;
}

div.print_header h1 {
  text-align: center;
}

table.print_body {
  border-spacing: 1px;
  background-color: #e7e7e7;
  color: #666;
  width: 100%;
}

table.print_body td,
table.print_body th { padding: 1px; }

table.print_body thead th {
  text-align: center;
  background: #f0f0f0;
  color: #666;
  border-bottom: 1px solid #999;
  border-left: 1px solid #fff;
}



PS: Il n'est pas possible d'être notifié par email des nouveux posts ?

8

Bon ben j'ai trouvé d'où venait le problème : il tournait en boucle dans le tfoot en fin de page.

ca sera corriger dans la prochaine version de html2pdf.

en cas de besoin, les modifications sont les suivantes :
File : html2pdf.class.php
Line : 95
Add this line :
var $isInTfoot = false; // indique si on est dans un tfoot

File : html2pdf.class.php
Line : 3311
Replace :
if ($HTML2PDF_TABLEAU[$param['num']]['td_y'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->h - $this->pdf->bMargin)
By :
if (!$this->isInTfoot && $HTML2PDF_TABLEAU[$param['num']]['td_y'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->h - $this->pdf->bMargin)

File : html2pdf.class.php
Line : 3324
Replace :
$this->MakeHTMLcode();
By :
						$this->isInTfoot = true;
						$this->MakeHTMLcode();
						$this->isInTfoot = false;

Ancien pseudo : lolo

9

Merci. Super vitesse de réaction smile