1

Hi,

I was looking for a way to convert my php files in pdf. I was working with the fpdf lib and 2 days ago a knew this project. In other forum, I get this code:

<?php
include ("seguridad_04.php");
session_start();

$_SESSION["codigobuscado01"] = $_POST['codigobuscado'];

ob_start();
include('cvtipo2imp.php');
$content_html = ob_get_clean();

// initialisation de HTML2PDF
require_once('./html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P','Letter','es', false, 'ISO-8859-15', array(0, 0, 0, 0));
$html2pdf->WriteHTML($content_html, isset($_POST['codigobuscado']));
$html2pdf->createIndex('', 25, 12, false, true, 1);
$html2pdf->Output('cv.pdf');
}
catch(HTML2PDF_exception $e) { echo $e; }
?>

It works, but the output is a web page and we need a pdf document with my own header and footer.

Could you help me?? Thanks

2

jjust look at the examplles in the zip file of html2pdf wink
Ancien pseudo : lolo

3

Thank you.

I get a pdf document.

But, I have the following problems:

1. The tag <fieldset> does not work.

2. In my php page, I have a table with a query that shows the rows and columns.In the web page it works. But in the pdf document, the space between rows is too big

3. And the last rows of this table are superimpose with the following table.

Could you help me?

4

Hi,

I need save to disk the pdf file. How I do this?


Thanks

5

Hi, when you create the pdf file, this appears with the features of the Acrobat (save, print, etc) in the menu bar. I had a mistake in my code, I changed vuehtml instead of codigobuscado. As Spipu said, we must follow the examples in the html2pdf folder.

Regards,

6

./3 => can you give a example of HTML code ?

./4 => read the WIKI

Ancien pseudo : lolo

7

Thanks, this is my php page:


<?php
include ("seguridad_04.php");
session_start();

$codigopers=$_SESSION["codigobuscado01"];

$con=mysql_connect("localhost","root","") or
die("No se puede conectar a la BD: " . mysql_error());

mysql_select_db("siper",$con);

$result01=mysql_query("select * from personal where codper='$codigopers'",$con);

while ($row01=mysql_fetch_array($result01))
{
$nombre=$row01["nombper"];
$ap_paterno=$row01["pateper"];
$ap_materno=$row01["mateper"];
$ci=$row01["cideper"];
$tin=$row01["tinaper"];
$f_ingreso=$row01["fingper"];
$f_nac=$row01["fnacper"];
$cod_dep=$row01["coddep"];
$cod_pro=$row01["codpro"];
$cod_loc=$row01["codloc"];
$cod_gra=$row01["codgra"];
$cod_esc=$row01["codesc"];
$cod_esp=$row01["codesp"];
$cod_cat=$row01["codcat"];
$cod_afp=$row01["codafp"];
$cod_gsa=$row01["codgsa"];
$cod_eci=$row01["codeci"];
}


$result11=mysql_query("select * from arresto where codper='$codigopers' order by fdocarr",$con);
$valida_filas_11=mysql_num_rows($result11);

$result12=mysql_query("select * from felicitaciones where codper='$codigopers' order by fdocban",$con);
$valida_filas_12=mysql_num_rows($result12);

<page backtop="40mm" backbottom="10mm" backleft="20mm" backright="20mm">
<page_header>
<table border="0">
<tr>
<td align="center" width="55"><img src="./fondos/escudoAB.JPG" width="50" height="50" /></td>
</tr>
<tr>
<td align="center" width="150"><font size="1">PROYECTO</font></td>
<td align="center" width="350"><strong>CURRICULUM VITAE</strong></td>
</tr>
<tr>
<td align="center"><font size="1">RR.HH.</font></td>
<td align="center" width="350"><strong>(Tipo 2)</strong></td>
</tr>
<tr>
<td align="center"><font size="1">La Paz - Bolivia</font></td>
</tr>
</table>
<hr style="border: 1px ridge #336699;" />
</page_header>
<page_footer>
<hr style="border: 1px ridge #336699;" />
<table align="center" frame="above" >
<tr>
<td style="text-align: left; width: 225px;">Divisi&oacute;n "H" - Archivo</td>
<td style="text-align: center; width: 200px;">[[page_cu]]-[[page_nb]]</td>
<td style="text-align: right; width: 225px;"><?php echo date('YmdHis'); ?></td>
</tr>
</table>
</page_footer>
<fieldset style="border: 1px ridge #336699; width: 650px;">
<table border="0">
<tr>
<td colspan="3" align="center"><strong>DATOS GENERALES</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="left"><strong>C&Oacute;DIGO:</strong></td>
<td colspan="2" lign="left"><?php echo $codigopers;?></td>
</tr>
<tr>
<td align="left"><strong>ESCALAF&Oacute;N:</strong></td>
<td align="left" colspan="2"><?php echo $escalafon;?></td>
</tr>
<tr>
<td align="left"><strong>GRADO:</strong></td>
<td colspan="2" align="left"><?php echo $grado;?></td>
</tr>
<tr>
<td align="left"><strong>ESPECILIDAD:</strong></td>
<td colspan="2" align="left"><?php echo $especialidad;?></td>
</tr>
<tr>
<td align="left"><strong>APELLIDO PATERNO:</strong></td>
<td colspan="2" align="left"><?php echo $ap_paterno;?></td>
</tr>
<tr>
<td align="left"><strong>APELLIDO MATERNO:</strong></td>
<td colspan="2" align="left"><?php echo $ap_materno;?></td>
</tr>
<tr>
<td align="left"><strong>NOMBRES:</strong></td>
<td colspan="2" align="left"><?php echo $nombre;?></td>
</tr>
<tr>
<td align="left"><strong>C&Eacute;DULA DE IDENTIDAD:</strong></td>
<td colspan="2" align="left"><?php echo $ci;?></td>
</tr>
<tr>
<td align="left"><strong>TIN:</strong></td>
<td colspan="2" align="left"><?php echo $tin;?></td>
</tr>
<tr>
<td align="left"><strong>FECHA DE INGRESO:</strong></td>
<td colspan="2" align="left"><?php echo $f_ingreso;?></td>
</tr>
<tr>
<td align="left"><strong>SEGURO SOCIAL:</strong></td>
<td colspan="2" align="left"><?php echo $seguro;?></td>
</tr>
<tr>
<td align="left"><strong>GRUPO SANGU&Iacute;NEO:</strong></td>
<td colspan="2" align="left"><?php echo $sangre;?></td>
</tr>
<tr>
<td align="left"><strong>ESTADO CIVIL:</strong></td>
<td colspan="2" align="left"><?php echo $ecivil;?></td>
</tr>
<tr>
<td align="left"><strong>FECHA DE NACIMIENTO:</strong></td>
<td colspan="2" align="left"><?php echo $f_nac;?></td>
</tr>
<tr>
<td align="left"><strong>LUGAR DE NACIMIENTO:</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left"><strong>Departamento: </strong></td>
<td align="left"><?php echo $departamento;?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left"><strong>Provincia: </strong></td>
<td align="left"><?php echo $provincia;?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left"><strong>Localidad: </strong></td>
<td align="left"><?php echo $localidad;?></td>
</tr>
</table>
</fieldset>
<hr style="border: 1px ridge #336699;" />
<br /><br />
<fieldset style="border: 1px ridge #336699; width: 650px;">

<table width= "600" border="0">
<tr>
<td >&nbsp;</td>
</tr>
<tr>
<td align="center"><strong>DEM&Eacute;RITOS</strong></td>
</tr>
</table>

<table>
<?php
if ($valida_filas_11!=0)
{
?>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<thead>
<tr>
<td align="center" style="width: 7px;"><strong>N°</strong></td>
<td align="center" style="width: 20px;"><strong>N°&nbsp;DOC</strong></td>
<td align="center" style="width: 30px;"><strong>FECHA</strong></td>
<td align="center" style="width: 80px;"><strong>CAUSA</strong></td>
<td align="center" style="width: 20px;text-wrap:hard-wrap align: center;"><strong>TIEMPO (Horas)</strong></td>
<td align="center" style="width: 70px;"><strong>AUTORIDAD</strong></td>
</tr>
</thead>

<?php
$contador=1;
while ($row11=mysql_fetch_array($result11))
{
?>
<tr>
<td align="center" style="width: 7px;"><?php echo $contador;?></td>
<td align="left" style="width: 20px;"><?php echo $row11["ndocarr"];?></td>
<td align="left" style="width: 30px;"><?php echo $row11["fdocarr"];?></td>
<td align="left" style="width:100;"><?php echo $row11["causarr"];?></td>
<td align="center" style="width: 20px;"><?php echo $row11["tiemarr"];?></td>
<td align="left" style="width: 50px;"><?php echo $row11["impoarr"];?></td>
</tr>
<?php
$contador++;
}
?>
<tr>
<td colspan="6"><strong>Nota: </strong>Los documentos que registran en el campo TIEMPO el valor 0, son memorandos de Llamada de Atenci&oacute;n</td>
</tr>
<?php
}
else
{
?>
<tr>
<td><h1>NO REGISTRA</h1></td>
</tr>
<?php
}

?>
</table>
</fieldset>
<hr style="border: 1px ridge #336699;" />
<br /><br />
<fieldset style="border: 1px ridge #336699; width: 650px;">

<table frame="above">
<tr>
<td colspan="2" align="center"><strong>FELICITACIONES</strong></td>
</tr>
<?php
if ($valida_filas_12!=0)
{
?>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"><strong>N°</strong></td>
<td align="center"><strong>N°&nbsp;DOC</strong></td>
<td align="center" width="100"><strong>FECHA</strong></td>
<td align="center"><strong>GLOSARIO</strong></td>
<td align="center"><strong>IMPONE</strong></td>
<td align="center"><strong>OBS</strong></td>
</tr>

<?php
$contador=1;
while ($row12=mysql_fetch_array($result12))
{
?>
<tr>
<td><?php echo $contador;?></td>
<td><?php echo $row12["ndocban"];?></td>
<td><?php echo $row12["fdocban"];?></td>
<td><?php echo $row12["glosban"];?></td>
<td align="center"><?php echo $row12["impoban"];?></td>
<td><?php echo $row12["obseban"];?></td>
</tr>
<?php
$contador++;
}
}
else
{
?>
<tr>
<td><h1>NO REGISTRA</h1></td>
</tr>
<?php
}
?>
</table>
</fieldset>

<hr style="border: 1px ridge #336699;" />

</page>

8

Hi Spipu, I worked with style and width in the table and I got the pdf file without big spaces between rows and the superimpose does not exist anymore.

But the tag fielset dos not work yet. Any idea?

Thanks

9

how can we help you if you just say "it does not work yet", without descrive the pb, and without a little HTML code example... (and not a big PHP example, like in ./7 )
Ancien pseudo : lolo

10

Hi, sorry for the poor example.

I have the problem, once again,with the superimpose between results of queries. The queries are int the top of the document.

How I can prevent this problem?.

This is a example (part of my code):

<table width="600" border="0">
<?php
if ($valida_filas_13!=0)
{
?>
<thead>
<tr>
<td style="text-align: center; width: 10px;"><strong>N°</strong></td>
<td style="text-align: center; width: 50px;"><strong>N°&nbsp;DOC</strong></td>
..............
</tr>
</thead>
<?php
$contador=1;
while ($row13=mysql_fetch_array($result13))
{
?>
<tr>
<td style="text-align: center; width: 10px;"><?php echo $contador;?></td>
<td style="text-align: center; width: 50px;"><?php echo $row13["ndocban"];?></td>
............
</tr>
<?php
$contador++;
}
}
else
{
?>
<tr>
<td><h1>NO REGISTRA</h1></td>
</tr>
<?php
}
?>
</table>
<hr style="border: 1px ridge #336699;" />
<br /><br />
<font style="text-align: center;"><strong>CONDECORACIONES</strong></font>
<br />
<hr style="border: 1px dashed #336699;" />
<table width="600" border="0">
<?php
if ($valida_filas_14!=0)
{
?>
<thead>
<tr>
<td align="center" width="10"><strong>N°</strong></td>
<td align="center" width="50"><strong>N°&nbsp;DOC</strong></td>
..........
</tr>
</thead>
<?php
$contador=1;
while ($row14=mysql_fetch_array($result14))
{
?>
<tr>
<td align="center" width="10"><?php echo $contador;?></td>
<td align="center" width="50"><?php echo $row14["ndoccon"];?></td>
.........
</tr>
<?php
$contador++;
}
}
else
{
?>
<tr>
<td><h1>NO REGISTRA</h1></td>
</tr>
<?php
}
?>
</table>tromb Fichier joint : Fichier joint : 6Tsq (example.JPG)