Foros del Web » Programando para Internet » PHP »

Wkhtmltopdf, problema en celdas.

Estas en el tema de Wkhtmltopdf, problema en celdas. en el foro de PHP en Foros del Web. Hola a tod@s. Estoy trabajando con la el programa Wkhtmltopdf, para generar pdfs. La parte visual me lo genera todo bien. Pero me he encontrado ...
  #1 (permalink)  
Antiguo 18/02/2016, 13:17
Avatar de wunderwaffen077  
Fecha de Ingreso: marzo-2014
Mensajes: 45
Antigüedad: 10 años, 1 mes
Puntos: 3
Wkhtmltopdf, problema en celdas.

Hola a tod@s.

Estoy trabajando con la el programa Wkhtmltopdf, para generar pdfs.
La parte visual me lo genera todo bien.

Pero me he encontrado un problemita al momento despues de la segunda hoja, y es que el contenido de las celdas cuando lo marco llevan un caracter raro (N sobre L), y no permite hacer busquedas rápidas dentro del PDF.

Imagen del resultado.
http://imgur.com/8UXusiQ

Parte del codigo..

Código PHP:
<?php
ob_start
();

?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="iso-9559-1"/>
        <style>
            body { font-family: helvetica; font-size: 7pt; }    
            pre { font-family: helvetica; }

            /*PARA QUE SALTE SOLO EN FILAS*/
            tr, td{
              page-break-inside: avoid !important;
            }
            
            @page {     
              margin-top:0.5cm;
              margin-bottom: 1cm;
              margin-left: 1cm;
              margin-right: 1cm;
            }
            
            table{
                border-collapse:collapse;
                width: 100%;        
            }
                        
            table td{
                padding-left: 2px;
            }
            
            table th{
                height:30pt;
            }            
            
            table.tdet td, .tdet th{
                border: 1pt solid #8D8D8D;

            }
            
            th.title1{
                border: 1px solid #fff;
            }
            th.title2{
                border-top: 1px solid #fff;
                border-left: 1px solid #fff;
                border-right: 1px solid #fff;
            }
                        
            #footer .page:after { content: counter(page, upper-roman); }
            #footer{
                margin-left:auto;
                margin-right:auto;
                margin-top:2em;
            }
            
        </style>
    </head>
    <body>    
        
        <div id="contenido">
            <table class="tdet">
                <tr class="title">
                    <th align="center" colspan="9" class="title1"><h1>PRODUCTOS PROMEDIO DE VENTAS</h1></th>
                </tr>
                <tr>
                    <th align="center" colspan="9" class="title2"><h4>DE : <?=date("d/m/Y"strtotime($ven_feemd)); ?> HASTA : <?=date("d/m/Y"strtotime($ven_feema)); ?> </h4></th>
                </tr>
                <tr class="title">
                    <th width="60px">CODIGO</th>
                    <th width="160px">DESCRIPCION</th>
                    <th width="60px">CANT. VENDIDA</th>
                    <th width="60px">PROMEDIO DIARIO</th>
                    <th width="60px">PROMEDIO SEMANAL</th>
                    <th width="60px">PROMEDIO QUINCENAL</th>
                    <th width="60px">PROMEDIO MENSUAL</th>
                    <th width="60px">STOCK ACTUAL</th>
                    <th width="100px">TIEMPO ESTIMADO</th>            
                </tr>
                <?php
                $color
=array('#ffffff','#E0F8E6');
                
$contador 0;
                for (
$i=0$i count($registros); $i++) {
                    
$contador++;                    

                    
$ite_item $registros[$i]['ite_item'];
                    
$ite_dsit $registros[$i]['ite_dsit'];
                    
$cantidad $registros[$i]['cantidad'];
                    
//$ndias = $registros[$i]['ndias'];
                    
$stock $registros[$i]['stock'];


                    
$p_diario $registros[$i]['p_diario'];
                    
$p_semanal $registros[$i]['p_semanal'];
                    
$p_quincenal $registros[$i]['p_quincenal'];
                    
$p_mensual $registros[$i]['p_mensual'];
                    
$anios $registros[$i]['anios'];
                    
$meses $registros[$i]['meses'];
                    
$dias $registros[$i]['dias'];

                    
$tiempo_est="";
                    if (
$anios>0) {
                        
$tiempo_est.=$anios." Años ";
                    }
                    if (
$meses>0) {
                        
$tiempo_est.=$meses." Meses ";
                    }
                    if (
$dias>0) {
                        
$tiempo_est.=$dias." Días";
                    }
                    
                    
//$v_deno = substr($v_deno."ASDASD ASDASD ASDASD ASDASDAS DAS ASDD",0,50);
                    
                    
$bgcolor="background-color:".$color[$contador%2].";";
                
?>
                <tr>
                    <td width="60px" align="center" style="<?=$bgcolor;?>"><?=$ite_item;?></td>
                    <td width="160px" align="left" style="<?=$bgcolor;?>"><?=conv_chars($ite_dsit);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($cantidad,2);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($p_diario,2);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($p_semanal,2);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($p_quincenal,2);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($p_mensual,2);?></td>
                    <td width="60px" align="right" style="<?=$bgcolor;?>"><?=number_format($stock,2);?></td>
                    <td width="100px" align="right" style="<?=$bgcolor;?>"><?=conv_chars($tiempo_est);?></td>
                </tr>        
                <?php
                
}
                
?>
            </table>
        </div>
    </body>
</html>

<?php
    $html 
ob_get_clean();
    
//$directorio = "/var/www/html/pdf/";
    
$filename "Productos_PromediosVentas_reporte_".date('_Ymd_his').'.pdf';
    
    
    
//DAR PERMISO 777 AL directorio "html" primero
    
$directorio "/var/www/html/pdf/";
    if(!
is_dir("$directorio")) 
        
mkdir("$directorio"0777);    

    try {
        
//$wkhtmltopdf = new Wkhtmltopdf(array('path' => APPLICATION_PATH . '/../public/uploads/'));
        
$options = array('margin-bottom' => '15mm','footer-spacing' => 5,'footer-html' => 'footer.html');
        
$wkhtmltopdf = new Wkhtmltopdf(array('path' => $directorio));//CREAR SI EN CASOoptions
        
$wkhtmltopdf->setOptions($options);
        
$wkhtmltopdf->setTitle("Presupuesto");
        
$wkhtmltopdf->setHtml($html);
        
$array=array('top' => 2'bottom' => 2'left' => 0'right' => 5);
        
$wkhtmltopdf->setMargins($array);
        
$wkhtmltopdf->setOrientation("Landscape");
        
$wkhtmltopdf->setPageSize("a3"); 
        
//$wkhtmltopdf->setUrl("http://epe.upc.edu.pe/");
        
$wkhtmltopdf->output(Wkhtmltopdf::MODE_EMBEDDED$filename);
    } catch (
Exception $e) {
        echo 
$e->getMessage();
    }
?>

Última edición por wunderwaffen077; 18/02/2016 a las 13:19 Razón: correcion

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 19:15.