Foros del Web » Programando para Internet » PHP »

problema con varias paginas en tcpdf

Estas en el tema de problema con varias paginas en tcpdf en el foro de PHP en Foros del Web. Buenos Dias, tengo el siguiente proble resulta que tengo que imprimir en pdf el resutado de una consulta la idea es que por pagina debo ...
  #1 (permalink)  
Antiguo 06/02/2016, 08:20
 
Fecha de Ingreso: agosto-2004
Mensajes: 440
Antigüedad: 19 años, 7 meses
Puntos: 2
problema con varias paginas en tcpdf

Buenos Dias,
tengo el siguiente proble resulta que tengo que imprimir en pdf el resutado de una consulta la idea es que por pagina debo imprimir una tabla con 2 columnas y 8 filas de informacion, el problema viene y resulta que la primera pagina siempre me la imprime en blanco y no se como hacer para evitar eso, utilizo fmod para dividir el valor de una variable contador que me este aplicando fmod con 4 y si el resultado es 0 cero deberia agregar una pagina nueva, el problema es que cuando dejo en cero nunca tiene en cuenta la primera pagina y me imprime en la primera solo 3 filas pero si la igualo a 1 al no tener en cuenta la 1 pagina es alli cuando sale en blanco e inicia a mostrar mis datos en la pagina 2, eso si correctamente pero dejando 1 en blanco. el tema es que la persona que no sepa esto dira que no salio nada en el pdf sin bajar a la siguiente hoja. mi codigo es el siguiente

Código PHP:
    //=======================TCPDF==================+
    // Include the main TCPDF library (search for installation path).
    
require_once('includes/tcpdf/tcpdf_include_detallada_rotulos.php');

    
// create new PDF document
    //se quita la extension y se cambia MYPDF por TCPDF
    
$pdf = new TCPDF('P'PDF_UNITPDF_PAGE_FORMATtrue'UTF-8'false);
    
    
// set document information
    
$pdf->SetCreator('cccc');
    
$pdf->SetAuthor('cccc');
    
$pdf->SetTitle('Rotulos Citibank');
    
$pdf->SetSubject('Rotulos Citibank');
    
//$pdf->SetKeywords('Solicitud, PDF, example, test, guide');
    
    // set default header data
    //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', PDF_HEADER_STRING);
    
$pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTHPDF_HEADER_TITLEPDF_HEADER_STRING);
    
    
    
// set header and footer fonts
    
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
    
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));
    
$pdf->setPrintHeader(false); //no imprime la cabecera ni la linea 
    
$pdf->setPrintFooter(false); //no imprime el pie ni la linea 
    
    // set default monospaced font
    
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    
    
// set margins
    
$pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOPPDF_MARGIN_RIGHT);
    
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    
    
// set auto page breaks
    
$pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);
    
    
// set image scale factor
    
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
    
// set some language-dependent strings (optional)
    
if (@file_exists(dirname(__FILE__).'/includes/tcpdf/lang/eng.php')) {
        require_once(
dirname(__FILE__).'/includes/tcpdf/lang/eng.php');
        
$pdf->setLanguageArray($l);
    }
    
// ---------------------------------------------------------
    // add a page
    
$pdf->AddPage();
    
    
//=======================FUNCIONALIDAD=====================================+
    
    ////CHEQUE
    
if ( $nombrePC == 'Cheque' )
    {
        
// set font
        
$pdf->SetFont('helvetica'''9);

        
$dataBc getDataDCGR$objDB$arrPG );//detalle
        
$tamanodataBc  sizeof($dataBc); //tamano 
        //echo '<pre>'; print_r( $dataBc ); echo '</pre>';
        
$k 0;
        for (
$i 0$i $tamanodataBc$i++)
        {
            
$fechaC $dataBc[0]['fecha_cargue'];
            
$fechaC explode('-'$fechaC);
            
$fechad $fechaC[2];
            
$fechad substr($fechaC[2], 0,2);
            
//echo '<pre>'; print_r( $fechad ); echo '</pre>';
            
$fecham $fechaC[1];
            
//echo '<pre>'; print_r( $dataBc); echo '</pre>';    
            
$archivo 'FC'.$fecham.$fechad.'09.PER';
    
            
//=======================DIBUJAR TABLA CON DATOS =====================================+

            
$html '        
                <table width="620" border="0" align="center">
                <tr>
                    <td width="65"  rowspan="2"><div align="center">IMAGEN</div></td>
                    <td width="150" ><div align="center">XXXX<br>XXXXX</div></td>
                    <td width="65" rowspan="2"><div align="center"><br>IMAGEN></div></td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="65"  rowspan="2"><div align="center">IMAGEN</div></td>
                    <td width="150" ><div align="center">XXXX<br>XXXXX</div></td>
                    <td width="65" rowspan="2"><div align="center"><br>IMAGEN</div></td>    
                </tr>
                <tr>
                    <td width="150" align="center">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <table width="80" border="1">
                            <tr>
                                <td align="center"><br><br>Cantidad '
.$dataBc[$i]['cantidad_cheques'].'</td>
                            </tr>
                        </table>
                    </td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="150" align="center">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <table width="80" border="1">
                            <tr>
                                <td align="center"><br><br>Cantidad '
.$dataBc[$i+1]['cantidad_cheques'].'</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                                <br>
                <tr>
                    <td width="100" height="20"  align="left">&nbsp;Nombre Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.$dataBc[$i]['nom_sucursal'].'</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="100" height="20"  align="left">&nbsp;Nombre Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.$dataBc[$i+1]['nom_sucursal'].'</td>
                </tr>
                <tr>
                    <td width="100" height="20" align="left">&nbsp;Direccion Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.$dataBc[$i]['dir_sucursal'].'</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="100" height="20" align="left">&nbsp;Direccion Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.$dataBc[$i+1]['dir_sucursal'].'</td>
                </tr>
                <tr>
                    <td width="100" height="25" align="left">&nbsp;Ciudad Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.utf8_encode($dataBc[$i]['ciudad']).'</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="100" height="25" align="left">&nbsp;Ciudad Oficina:</td>
                    <td width="180" colspan="2" align="left">'
.utf8_encode($dataBc[$i+1]['ciudad']).'</td>
                </tr>
                <tr>
                    <td width="100" height="25" align="left">&nbsp;Contacto:</td>
                    <td width="180" colspan="2" align="left">'
.utf8_encode($dataBc[$i]['contacto']).'
                        <br>
                        <br>
                        <br>
                    </td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                    <td width="100" height="25" align="left">&nbsp;Contacto:</td>
                    <td width="180" colspan="2" align="left">'
.utf8_encode($dataBc[$i+1]['contacto']).'
                        <br>
                        <br>
                        <br>                
                    </td>
                </tr>'
;
                
$i$i+1//aumento a $i en 1 para que continue con la fila siguiente
                
$k $k+1//agrego una variable para saber cuando llega a 4 y a 8 y asi sucesivamente
                
            
$html .='</table>';        
            
//echo $i." valor de i <br>";    
            //echo $k." valor de K <br>";
            
$nil fmod($k'4'); //aqui aplico fmod para que el resultado sea con el que agrego una pagina nueva    
            //echo $nil." valor de res<br><br>";

            
if ($nil==1//si dejo == 0 en la primera imprime solo 3 filas, y si la dejo == 1 arranca en la segunda dejando la primera en blanco
            
$pdf->AddPage();

            
// print a block of text using Write()
            
$pdf->writeHTML($htmltruefalsefalsefalse'');
                                    
        }
//for $i
        
unset($dataBc);
    }
//if CG

    // close and output PDF document
    
$pdf->Output('exp_rotuloscity.pdf''I');
    
    
//============================================================+
    // END OF FILE
    //============================================================+
    
}//if arrpg
////////////////// 
ayuda por favor
__________________
paty :adios:

Etiquetas: fecha, html, tabla, tcpdf, variable
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 17:13.