Foros del Web » Programando para Internet » PHP »

convertir a pdf con html2pdf

Estas en el tema de convertir a pdf con html2pdf en el foro de PHP en Foros del Web. hola, estoy usando html2pdf para exportar unas tablas a pdf.... yo en mi BD tengo una tabla que se llama Procesos cuando se hace una ...
  #1 (permalink)  
Antiguo 05/08/2010, 09:43
 
Fecha de Ingreso: abril-2010
Mensajes: 56
Antigüedad: 13 años, 11 meses
Puntos: 0
convertir a pdf con html2pdf

hola, estoy usando html2pdf para exportar unas tablas a pdf....

yo en mi BD tengo una tabla que se llama Procesos
cuando se hace una consulta selecciona el proceso y muetsra en pantalla el proceso en unas etsructuras de tablas

aca hay la posibilidad de exportar a pdf... con html2pdf creo la tbal y la envio al pdf
las tablas las lleno con informacion que tengo de la BD entonces es variable.. el contenido dentro de un <td></td> es variable y peude en algunos casos ser mas grande o mas pequeño....

y cuando se acaba la hoja y empieza una nueva se daña la tabla queda descuadrada.. muy feo en algunos casos cuadno todo el conenido de el <td> no cabe simplemente pasa toda es afila a la hoja siguiente pero en lagunos casos no o hace y se vuelve totalmente loco no se porq

puse en la tabla </thead> <tfoot> pero el <tfoot> cuado va a cambiar de hoja lo repite hasta q se llena el campo en la hoja q estba y ahi i pasa a la siguiente...

si aguien ha usado html2pdf.. y sepa como cuadrar bn estas tablas dinamicas en el pdf porfa cualquier ayuda muchas gracias

pongo parte del codigo q tengo para generar el pdf...

Código PHP:
<?php
  session_start
(); 
  
ob_start();
  include(
"Conectar.php");

//recuperacion de variables
$proceso=$_GET['idP'];
$idUsuario     =  $_SESSION["Idusuario"];

   
//Sentencia SQL para buscar proceso 
   
$result =  mysql_query("SELECT * FROM Proceso where idProceso='$proceso'",$link) or die(mysql_error());
   
$r_ok mysql_fetch_array($result); 
        
$nombre        =  $r_ok['nombre'];
        
$fecha           =  $r_ok['fecha'];
                                
$descripcion  =  nl2br($r_ok['descripcion']);
        
$recusros      =  nl2br($r_ok['recursos']);
                                
$resultados   =  nl2br($r_ok['resultados']); 

 
//sub procesos
    
$procesos=mysql_query("SELECT SubProceso.nombre as nombre, Empleado.nombre as empleado, Empleado.apellido as apellido FROM SubProceso,Empleado where Proceso_idProceso='$proceso' AND Empleado.idEmpleado=Procedimiento.Empleado_idEmpleado",$link) or die(mysql_error()); 
?>   
       
<page orientation="L" backtop="20mm" backbottom="20mm" backleft="10mm" backright="50mm">
    <page_header>
        <table style="width: 115%; border: solid 1px black;">
            <tr>
             <th BGCOLOR="#CCD6EB">procesos</th>
           </tr>        
        </table>
    </page_header>
    <page_footer>
        <table style="width: 100%; border: solid 1px black;">
            <tr>
                <td style="text-align: left;    width: 50%">PDF</td>
                <td style="text-align: right;    width: 50%">page [[page_cu]]/[[page_nb]]</td>
            </tr>
        </table>
    </page_footer>

    <table style="width: 114%;border: solid 1px #5544DD; border-collapse: collapse" align="center">
        <thead>
            <tr>
                <th colspan="2" style="width: 88%; text-align: center; border: solid 1px black; background: #CCD6EB">SUBPROCESOS DEL PROCESO</th>
            </tr>
            <tr>
                <th style="width: 49%; text-align: center; border: solid 1px black; background: #CCD6EB">SUB PROCESO</th>
                <th style="width: 50%; text-align: center; border: solid 1px black; background: #CCD6EB">RESPONSABLE</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th  style="border: solid 1px black;width: 50%;text-align: justify;"><?php echo $proced_proceso?></th>
                <th  style="border: solid 1px black;width: 50%;text-align: justify;"><?php echo $responsableP?></th>
            </tr>
                <?php while($row mysql_fetch_array($procesos)){
                  
$sub_proceso $row['nombre'];
                  
$responsableP $row['empleado']. " " $row['apellido']; ?>
            <tr>
                <th  style="border: solid 1px black;width: 50%;text-align: justify;"><?php echo $sub_proceso?></th>
                <th  style="border: solid 1px black;width: 50%;text-align: justify;"><?php echo $responsableP?></th>
            </tr>
            <?php ?>
        </tbody>
    </table>

<table style="width: 100%;border: solid 1px #5544DD; border-collapse: collapse" align="center">
        <thead>
            <tr>
                <th colspan="4" style="text-align: center; border: solid 1px black; background: #CCD6EB">CONTROL DE CAMBIOS</th>
            </tr>
            <tr>
                <th style="width: 15%; text-align: center; border: solid 1px black; background: #CCD6EB">FECHA</th>
                <th style="width: 10%; text-align: center; border: solid 1px black; background: #CCD6EB">VERSION</th>
                <th style="width: 78%; text-align: center; border: solid 1px black; background: #CCD6EB">DESCRIPCION</th>
                <th style="width: 10%; text-align: center; border: solid 1px black; background: #CCD6EB">ESTADO</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $fecha?></th>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $version?></th>
                <th  style="width: 78%;border: solid 1px black;text-align: justify;"><?php echo $cambios?></th>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $ESTA?></th>
            </tr>
            <?php while($row2 mysql_fetch_array($res)){
                  
$nomb  $row2['version'] ;
                  
$cod   nl2br(htmlspecialchars($row['descripcion']));
                  
$date  $row2['fecha'] ;
                  
$est   $row2['ESTADO'] ;
                  
$estado"No Aprobado";
                    if (
$est==1) {$estado="Aprobado"; } ?>
            <tr>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $date?></th>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $nomb?></th>
                <th  style="width: 40%;border: solid 1px black;text-align: justify;"><?php echo $cod?></th>
                <th  style="border: solid 1px black;text-align: center;"><?php echo $estado?></th>
            </tr>
            <?php ?>
        </tbody>
       <tfoot>
        <tr>
            <tr>
                <th colspan="4" style="text-align: center; border: solid 1px black; background: #CCD6EB">VITACORA</th>
            </tr>
            <tr>
                <th style="width: 15%; text-align: center; border: solid 1px black; background: #CCD6EB">FECHA</th>
                <th style="width: 10%; text-align: center; border: solid 1px black; background: #CCD6EB">VERSION</th>
                <th style="width: 78%; text-align: center; border: solid 1px black; background: #CCD6EB">DESCRIPCION</th>
                <th style="width: 10%; text-align: center; border: solid 1px black; background: #CCD6EB">ESTADO</th>
            </tr>
        </tr>
    </tfoot>
    </table>

</page>
<?php 
  $content 
ob_get_clean();
  require(
"fpdf/html2pdf/html2pdf.class.php");  
  
    try
    {
        
$html2pdf = new HTML2PDF('P','A4''fr'false'ISO-8859-15'3);
        
$html2pdf->pdf->SetDisplayMode('fullpage');
        
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
        
$html2pdf->Output('MIPDF.pdf');
    }
    catch(
HTML2PDF_exception $e) { echo $e; }
?>
esa es parte del codigo no esta completo... ...
comod eica el rpoblea es cuando cambia de hoja... se vuelve loco...

gracias

Etiquetas: pdf
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:20.