1

Hi,
I'm trying to create a pdf from some html gjenerated from php. I'm getting one error :
--------------------------------------------------------------------------------------------------
ERREUR n°4
Fichier : C:\Projects\ardesa\prod\html2pdf\parsingHTML.class.php
Ligne : 127

Code HTML non valide, les balises ne sont pas fermées dans le bon ordre.
Etat :

Array
(
    [0] => table
    [1] => tr
    [2] => td
)



HTML : ...span></strong></p> </td> </tr> </table> <p>&nbsp;</p> <table ...

-------------------------------------------------------------------------------------------------------------
the html code is html4.0 valid I checked with the Firefox HTML validator
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Print</title>
</head>
<body>

<p ><strong><span  style='font-family:Tahoma'>&nbsp;</span></strong></p>


<table   cellspacing=0 cellpadding=0  style='width:489.05pt;margin-left:3.5pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:283.5pt;padding:0in 3.5pt 0in 3.5pt'>
  <b><strong><span  style='font-size: 12.0pt;text-transform:uppercase;font-weight:bold'>XXXXXXXX</span></strong></b>

  <br ><strong><span  style='font-size:  12.0pt'>XXXX</span></strong>
  <p ><strong><span  style='font-size: 12.0pt'>XXXXXX</span></strong></p>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:205.55pt;padding:0in 3.5pt 0in 3.5pt'>
  <b><strong><span  style='font-size:12.0pt;
  font-variant:normal !important'>XXXXXX</span></strong></b>
  <strong><br><span  style='font-size: 12.0pt'>XXXXXXX</span></strong>

  <p>
  <strong><span  style='font-size:
  12.0pt'>XXXXXX</span></strong></p>
  </td>
 </tr>
</table>

<table   cellspacing=0 cellpadding=0
 style='margin-left:53.15pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:141.75pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size:
  12.0pt'>RC </span></strong>

  </td>
 </tr>
</table>
<p>&nbsp;</p>
<table   cellspacing=0 cellpadding=0 
 style='width:6.3in;margin-left:53.15pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:200.75pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size:
  12.0pt'>Annuel</span></strong>
  </td>
  
  <td  valign=top style='width:190.8pt;padding:0in 3.5pt 0in 3.5pt'>

  <strong><span  style='font-size:12.0pt;font-weight:bold'>Voir Conditions Particulières</span></strong>
  </td>
 </tr>
 
</table>
<p>&nbsp;</p>
<table   cellspacing=0 cellpadding=0  style='width:506.75pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:74.4pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>S 204.170</span></strong></p>

  <td  valign=top style='width:73.6pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:89.4pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>26 02 08 à 0h</span></strong></p>
  </td>
  <td  valign=top style='width:42.55pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>A</span></strong></p>

  </td>
  <td  valign=top style='width:56.7pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>2 mois</span></strong></p>
  </td>
  <td  valign=top style='width:99.2pt;padding:0in 3.5pt 0in 3.5pt'>
  <p><strong><span  style='font-size:12.0pt'>Société</span></strong></p>
  </td>
  <td  valign=top style='width:70.9pt;padding:0in 3.5pt 0in 3.5pt'>

  <p   style='text-align:center'><strong><span  style='font-size:12.0pt'>01 01</span></strong></p>
  </td>
 </tr>
</table>
<p>&nbsp;</p>
<table   cellspacing=0 cellpadding=0 
 style='width:6.3in;margin-left:53.15pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:66.75pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size:  12.0pt'>01 01 10</span></strong>

  </td>
  <td  valign=top style='width:75.0pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size:  12.0pt'>31 12 10</span></strong>
  </td>
  <td  valign=top style='width:77.95pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size: 12.0pt'>750 €</span></strong>
  </td>
  <td  valign=top style='width:63.8pt;padding:0in 3.5pt 0in 3.5pt'>

  <strong><span  style='font-size: 12.0pt'>23 €</span></strong>
  </td>
  <td  valign=top style='width:49.6pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size: 12.0pt'>-</span></strong>
  </td>
  <td  valign=top style='width:56.7pt;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size: 12.0pt'>69,50 €</span></strong>

  </td>
  <td  valign=top style='width:63.8pt;padding:0in 3.5pt 0in 3.5pt'>
  <b><strong><span  style='font-size:12.0pt;font-weight:bold'>842,50 €</span></strong></b>
  </td>
 </tr>
 <tr>
 <td>
 </td>

 <td>
 </td>
 <td>
 </td>
 <td>
 </td>
 <td>
 </td>
 <td>

 </td>
 <td>
 </td>
 </tr>
 <tr>
  <td  valign=top style='width:66.75pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:75.0pt;padding:0in 3.5pt 0in 3.5pt'>

  <p ><strong><span  style='font-size:
  12.0pt'>100 %</span></strong></p>
  </td>
  <td  valign=top style='width:77.95pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:63.8pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>

  <td  valign=top style='width:49.6pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:56.7pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:63.8pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>&nbsp;</span></strong></p>
  </td>

  
 </tr>
</table>
<p>&nbsp;
</p>
<p>&nbsp;
</p>
<table   cellspacing=0 cellpadding=0  style='margin-left:64.4pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:80.5pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:7.0pt'>&nbsp;</span></strong></p>
  <p ><strong><span  style='font-size:12.0pt'>750 €</span></strong></p>

  </td>
  <td  valign=top style='width:70.85pt;padding:0in 3.5pt 0in 3.5pt'>
  <p   style='text-align:center'><strong><span  style='font-size:12.0pt'>23 €</span></strong></p>
  </td>
  <td  colspan=2 valign=top style='width:99.25pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><b><strong><span  style='font-size:7.0pt;font-weight:bold'>&nbsp;</span></strong></b></p>
  <p ><b><strong><span  style='font-size:12.0pt;font-weight:bold'>842,50 €</span></strong></b></p>
  </td>

  <td  colspan=2 valign=top style='width:37.55pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:7.0pt'>&nbsp;</span></strong></p>
  <p ><strong><span  style='font-size:12.0pt'>138,75 €</span></strong></p>
  </td>
  <td  valign=top style='width:53.15pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:7.0pt'>&nbsp;</span></strong></p>
  <p ><strong><span  style='font-size:12.0pt'>703,75 € </span></strong></p>
  </td>

 </tr>
 <tr style='height:0pt;'>
  <td  style='border:none'></td>
  <td  style='border:none'></td>
  <td  style='border:none'></td>
  <td  style='border:none'></td>
  <td  style='border:none'></td>
  <td  style='border:none'></td>
  <td  style='border:none'></td>

 </tr>
 <tr>
  <td  valign=top style='width:80.5pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span style='font-size:12.0pt;color:red'>&nbsp;</span></strong></p>
  </td>
  <td  colspan=2 valign=top style='width:70.85pt;padding:0in 3.5pt 0in 3.5pt'>
  
  </td>
  <td  colspan=2 valign=top style='width:99.25pt;padding:0in 3.5pt 0in 3.5pt'>

  </td>
  <td  valign=top style='width:37.55pt;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span style='font-size:12.0pt;color:red'>&nbsp;</span></strong></p>
  </td>
  <td  valign=top style='width:53.15pt;padding:0in 3.5pt 0in 3.5pt'>
  <p   ><b><strong><span  style='font-size:12.0pt;color:red;font-weight:bold'>703,75 €</span></strong></b></p>
  </td>
 </tr>

 
</table>


<p ><strong><span >&nbsp;</span></strong></p>

<p  style='margin-left:15.0pt'><strong><span
 style='font-size:14.0pt'>&nbsp;</span></strong></p>

<table   cellspacing=0 cellpadding=0
 style='margin-left:152.35pt;border-collapse:collapse'>
 <tr>
  <td  valign=top style='width:3.15in;padding:0in 3.5pt 0in 3.5pt'>
  <p ><strong><span  style='font-size:
  12.0pt'>            XXXXXXXX</span></strong></p>

  </td>
 </tr>
 <tr>
  <td  valign=top style='width:3.15in;padding:0in 3.5pt 0in 3.5pt'>
  <strong><span  style='font-size:12.0pt;text-align:right'>             S 204.170</span></strong>
  </td>
 </tr>

 <tr>

  <td  valign=top style='width:3.15in;padding:0in 3.5pt 0in 3.5pt'>
  <p   style='text-align:right'><strong><span  style='font-size:8.0pt'>Le 22 octobre 2009</span></strong></p>
  </td>
 </tr>
 
</table>

</body>
</html>

--------------------------------------------------------------
Any ideas?

Thanks

2

Additional info :
The php code to generate the pdf :
--------------------------------------------------------------
<?php
	// récupération du contenu HTML
	include_once("functions2.php");
	connection();
 	ob_start();
// ici il faut inclure la page qui prépare le code html qui va être converti en pdf
   $idop=$_GET["id"];
   include_once("commission_template.php");
   
   //displayReport($_GET["id"]);
   $content = ob_get_clean();

		// conversion HTML => PDF

	require_once("html2pdf/html2pdf.class.php");
	$html2pdf = new HTML2PDF('P','A4','fr');
	$html2pdf->WriteHTML($content, false);

	$time=time();
	$nomfic='a_'.$time.'.pdf';
	$html2pdf->Output($nomfic);
	header('Content-type: application/pdf');
	header('Content-Disposition: inline; filename="'.$nomfic.'"');
	readfile($nomfic);
?>


-------------------------------

3

in first : read the examples tongue

in second : why write this ??? <p style='...'><strong><span style='...'>

<p style="font-weight: bold; ...; ..."> is better and faster...
Ancien pseudo : lolo

4

Anything wrong with my code?
I removed the <strong></strong>. same problem.
-------------------------------------------------------------------------------------
ERREUR n°4
Fichier : C:\Projects\ardesa\prod\html2pdf\parsingHTML.class.php
Ligne : 127

Code HTML non valide, les balises ne sont pas fermées dans le bon ordre.
Etat :

Array
(
    [0] => 
    [1] => body
    [2] => table
    [3] => tr
    [4] => td
)



HTML : ...'>01 01</span></p> </td> </tr> </table> <p>&nbsp;</p> <table ...

---------------------------------------------------------------------------------------------------------

5

Spipu (./3) :
in first : read the examples tongue.gif


and some td tags are not closed...
Ancien pseudo : lolo

6

I'm reading the examples....
Cannot find and unclosed <td> tags???

7

in examples, there is no html, head, title, and body tags....

and there is a wiki : http://wiki.spipu.net/doku.php?id=html2pdf:en:page

you make a pdf document with pages, not a html document with head and body...

about td tags :

<table cellspacing=0 cellpadding=0 style='width:506.75pt;border-collapse:collapse'>
<tr>
<td valign=top style='width:74.4pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>S 204.170</span></strong></p>

<td valign=top style='width:73.6pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>&nbsp;</span></strong></p>
</td>
<td valign=top style='width:89.4pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>26 02 08 à 0h</span></strong></p>
</td>
<td valign=top style='width:42.55pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>A</span></strong></p>

</td>
<td valign=top style='width:56.7pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>2 mois</span></strong></p>
</td>
<td valign=top style='width:99.2pt;padding:0in 3.5pt 0in 3.5pt'>
<p><strong><span style='font-size:12.0pt'>Société</span></strong></p>
</td>
<td valign=top style='width:70.9pt;padding:0in 3.5pt 0in 3.5pt'>

<p style='text-align:center'><strong><span style='font-size:12.0pt'>01 01</span></strong></p>
</td>
</tr>
</table>

[nosmile]

is this so difficult to read before asking something ???
Ancien pseudo : lolo

8

Ce genre de questions a l'air quand même d'être particulièrement récurrent. Je me demande si ça n'est pas parceque le nom de ton soft (HTML2PDF) suggère qu'on peut convertir une page HTML en PDF directement, hors ce n'est pas du tout le cas (il faut un format bien spécifique, qui ressemble beaucoup à de l'HTML mais qui n'en est pas puisque certaines balises doivent disparaitre et d'autre être ajoutées).

Peut-être que ça pourrait valoir le coup de préciser ça clairement sur ton site ?
avatar
All right. Keep doing whatever it is you think you're doing.
------------------------------------------
Besoin d'aide sur le site ? Essayez par ici :)

9

You were right about the td tags. I checked the file with the validator and no errors were found...anyway

it worked after closing the tag and putting the <page> .
Thanks for the help.

You can be less ironic next time, who knows may you will need help...and not much time to read.


Luan,


10

Zephyr (./8) :
Ce genre de questions a l'air quand même d'être particulièrement récurrent. Je me demande si ça n'est pas parceque le nom de ton soft (HTML2PDF) suggère qu'on peut convertir une page HTML en PDF directement, hors ce n'est pas du tout le cas (il faut un format bien spécifique, qui ressemble beaucoup à de l'HTML mais qui n'en est pas puisque certaines balises doivent disparaitre et d'autre être ajoutées).

Peut-être que ça pourrait valoir le coup de préciser ça clairement sur ton site ?


Totally agree.

11

./8 ./10 => ben si les gens lisaient les exemples et le fichier about, ils pourrait lire ceci :

Cette librairie est là pour faciliter la génération de documents PDF, pas pour convertir n'importe quelle page HTML.

mais je pense que de nos jours les gens ont perdu l'habitude de réfléchir, et veulent que tout leur tombe tout cuit dans la bouche... désespérant...

./9 => i'm so "ironic" because to much people are asking before reading...and not only on this forum... on lots of forums !
Ancien pseudo : lolo

12

je viens de rajouter le texte suivant sur la page d'accueil du site :
Cette librairie a été faite pour faciliter la création de fichiers PDF, non pour convertir directement une page HTML. Vous ne pouvez pas utiliser les balises <html>, <head>, <body>. Lisez attentivement les exemples.
Ancien pseudo : lolo

13

Bah oui d'accord mais bon, c'est comme si je faisais un soft qui s'appelle wav2mp3 converter et que j'explique sur une page "about" qu'en fait ça ne traite pas les wav, il faut d'abord leur faire subir une modification : c'est assez déroutant.

Le texte que tu indiques en gras pourrait gagner à être plus visible, parceque moi quand je vais sur html2pdf, le 1er truc que je vois c'est ça :
HTML2PDF est un convertisseur de code HTML vers PDF écrit en PHP4, utilisant la librairie Fpdf d'Olivier PLATHEY. Il permet la conversion d'HTML 4.01 valide au format PDF, et est distribué sous license LGPL.

Et c'est faux : un code HTML 4.01 valide ne pourra pas être converti par HTML2PDF. Pour le coup je comprends totalement la quantité de gens qui viennent poser cette question sur le forum.
avatar
All right. Keep doing whatever it is you think you're doing.
------------------------------------------
Besoin d'aide sur le site ? Essayez par ici :)

14

> i'm so "ironic" because to much people are asking before reading...and not only on >this forum... on lots of forums !

Sure they do. You are not forced to answer I suppose....if you are, be more polite because it is not our fault.

Regards,

15

./13 => c'est vrai que t'as pas tort... je vais peut-être rajouté une compatibilité avec les pages classiques afin d'extraire le contenu du body, ainsi que les styles contenus dans le head. à étudier. mais ca éviterait beaucoup de questions en effet...

./14 => sorry for my bad mood, I was hungry ... sick cheeky

juste a little question :

You were right about the td tags. I checked the file with the validator and no errors were found...anyway

what validator do you use ?
Ancien pseudo : lolo

16

>>>the html code is html4.0 valid I checked with the Firefox HTML validator addonn

17

and it does not detect a missing td ? Perhaps because it is not required to close the <td> tags ...
Ancien pseudo : lolo

18

No errors, no warnings. ... probably it is not required.

19

HTML is SGML, and you are allowed to not close tags, unlike XML
avatar
Proud to be CAKE©®™


GCC4TI importe qui a problème en Autriche, pour l'UE plus et une encore de correspours nucléaire, ce n'est pas ytre d'instérier. L'état très même contraire, toujours reconstruire un pouvoir une choyer d'aucrée de compris le plus mite de genre, ce n'est pas moins)
Stalin est l'élection de la langie.