Je test actuellement html2pdf mais je quelque chose m'échappe.
Si je regarde l'exemple 0 et le pdf généré , je me dit nickel!
Je test donc la même source html (img et verdana enlevé pour éviter les erreurs, verdana remplacé par arial et les balises img par des "B") avec la version 3.30 (php 4.3.10-22 debian) sauf que le pdf généré ne donne pas du tout le même résultat que online: tout est 3x trop grand
Voici le code utilisé pour le test et le pdf généré en PJ
<?php
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Restitution HTML</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" >
</head>
<body style="padding: 10px; font-size: 10pt;font-family: Arial;">
<style type="text/Css">
<!--
.test1
{
border: solid 1px #FF0000;
background: #FFFFFF;
border-collapse: collapse;
}
-->
</style>
<hr>PAGE : style="font-size: 14px"<hr><div style="font-size: 14px">
<span style="font-weight: bold; font-size: 18pt; color: #FF0000; font-family: Times">Bonjour, voici quelques exemples<br></span>
<br>
Retours à la ligne autorisés : <br>, <br >, <br/>, <br /> <br />
<br>
Barre horizontale <hr><hr style="height: 4mm; background: #AA5500; border: solid 1mm #0055AA">
Exemple de lien : <a href="http://html2pdf.fr/" >le site HTML2PDF</a><br>
<br>
Image : <br>
<br>
Alignement horizontal des DIVs et TABLEs<br />
<table style="text-align: center; border: solid 2px red; background: #FFEEEE;width: 40%" align="center"><tr><td style="width: 100%">Test 1</td></tr></table><br />
<table style="text-align: center; border: solid 2px red; background: #FFEEEE;width: 40%; margin: auto"><tr><td style="width: 100%">Test 2</td></tr></table><br />
<div style="text-align: center; border: solid 2px red; background: #FFEEEE;width: 40%; margin: auto">Test 3</div><br />
test de tableau imbriqué :<br>
<table border="1" bordercolor="#007" bgcolor="#AAAAAA" align="center">
<tr>
<td border="1">
<table style="border: solid 1px #FF0000; background: #FFFFFF; width: 100%; text-align: center">
<tr>
<th style="border: solid 1px #007700;width: 50%">C1 «</th>
<td style="border: solid 1px #007700;width: 50%">C2 «</td>
</tr>
<tr>
<td style="border: solid 1px #007700;width: 50%">D1 € «</td>
<th style="border: solid 1px #007700;width: 50%">D2 € «</th>
</tr>
</table>
</td>
<td border="1">A2</td>
<td border="1">AAAAAAAA</td>
</tr>
<tr>
<td border="1">B1</td>
<td border="1" rowspan="2">
<table class="test1">
<tr>
<td style="border: solid 2px #007700">E1</td>
<td style="border: solid 2px #000077; padding: 2mm">
<table style="border: solid 1px #445500">
<tr>
<td>
B
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="border: solid 2px #770000">F1</td>
<td style="border: solid 2px #007777">F2</td>
</tr>
</table>
</td>
<td border="1"><hr>barcode : type="EAN13" value="45" style="width: 30mm; height: 6mm; font-size: 4mm"<hr></td>
</tr>
<tr>
<td border="1"><hr>barcode : type="C39" value="HTML2PDF" label="none" style="width: 35mm; height: 8mm"<hr></td>
<td border="1">A2</td>
</tr>
</table>
<br>
Exemple avec border et padding : <br>
<table style="border: solid 5mm #770000; padding: 5mm;" cellspacing="0" >
<tr>
<td style="border: solid 3mm #007700; padding: 2mm;">B</td>
</tr>
</table>
B<br>
<br>
<table style="border: solid 1px #440000; width: 150px" cellspacing="0"><tr><td style="width: 100%">Largeur : 150px</td></tr></table><br>
<table style="border: solid 1px #440000; width: 150pt" cellspacing="0"><tr><td style="width: 100%">Largeur : 150pt</td></tr></table><br>
<table style="border: solid 1px #440000; width: 100mm" cellspacing="0"><tr><td style="width: 100%">Largeur : 100mm</td></tr></table><br>
<table style="border: solid 1px #440000; width: 5in" cellspacing="0"><tr><td style="width: 100%">Largeur : 5in</td></tr></table><br>
<table style="border: solid 1px #440000; width: 80%" cellspacing="0"><tr><td style="width: 100%">Largeur : 80% </td></tr></table><br>
</div><hr>
</body>
</html>
<?php
$content = ob_get_clean();
require_once('/xxxxxxxxxxxxx/html2pdf_v3.30/html2pdf.class.php');
$html2pdf = new HTML2PDF('P','A4', 'fr');
$html2pdf->writeHTML($content);
$html2pdf->Output('test.pdf');
?>
Fichier joint : test.pdf
Quel est la raison de cet effet?
Car du coup cela complique un peu la tache dans la conception ^^
Autre chose, existe-il une sorte de règle A4~=1024px? si non à part faire 26 test comment savoir que la page html rentrera parfaitement sur 1 page par exemple?
Merci
Yoann