Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/04/2009, 12:26
ana86
 
Fecha de Ingreso: abril-2009
Mensajes: 3
Antigüedad: 15 años, 11 meses
Puntos: 0
Creación de PDF en php

Hola...espero y alguna persona me pueda ayudar...
mi problema es el siguiente:
1.-Puedo realizar el pdf pero lo que no se!!!...es como hacerle para que cuando reciba los datos de la BD y el campo tenga un dato largo.....pues q al llegar al margen q le corresponde al campo que estoy mandando a imprimir...pues q me haga un salto de línea.....para q no ocupe el espacio de otros campos de impresion.....EN UNA PAGINA RECIBO LOS VALORES DE LA VARIABLE Y ME LLAMA A LA SIGUIENTE PAG. este es mi código para generar mi pdf


<?php
include("conexion.php");
require('fpdf.php');

class Imprimir{
function reporte($fechaini,$fechafin){
define('FPDF_FONTPATH','./font/');

$link = Conectarse();
$pdf=new PDF('P','mm','letter');
$pdf->AddPage();
$pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont('');
$pdf->Cell(0,5,'XXX',0,0,'C',1);

$PieInforme='EEEE';

$date = new DateTime("$Fecha");
$Fecha = $date->format('d/m/Y');
$pdf->Ln(10);
$fechai=date('d-M-Y',strtotime($fechaini));
$fechaf=date('d-M-Y',strtotime($fechafin));
$pdf->Cell(25,5,'Reporte De: ','LTRB',0,'L',1);
$pdf->Cell(30,5,$fechai,'LTRB',0,'C',1);
$pdf->Cell(7,5,'Al: ','LTRB',0,'L',1);
$pdf->Cell(30,5,$fechaf,'LTRB',0,'C',1);
$posX = $pdf->GetX() + 64;

$pdf->SetX($posX);
$pdf->Cell(14,5,'Fecha: ','LTRB',0,'L',1);
$pdf->Cell(25,5,$Fecha,'LTRB',0,'C',1);
$pdf->Ln(10);

$ssql="SELECT * from tabla WHERE fecha_rep BETWEEN '$fechaini' AND '$fechafin';";

$header=array('Fecha de Rep.','Equipo','Estado','Problemática','Solución') ;
$w=array(30,20,20,70,55);
for($i=0;$i<count($header);$i++)
{
$pdf->Cell($w[$i],7,$header[$i],1,0,'C',1);
}

$pdf->Ln();
$rsReport=mysql_query($ssql,$link);
$fill = 0;
$renglon = 0;
$pdf->SetFont('Arial','',8);
while($fila = mysql_fetch_array($rsReport))
{
$pdf->Cell($w[0],6,$fila[10],'LTRB',0,'C',$fill);
$pdf->Cell($w[1],6,$fila[4],'LTRB',0,'C',$fill);
$pdf->Cell($w[2],6,$fila[21],'LTRB',0,'C',$fill);
$pdf->Cell($w[3],6,$fila[5],'LTRB',0,'C',$fill);
$pdf->Cell($w[4],6,$fila[6],'LTRB',0,'C',$fill);
$pdf->Ln();
$fill=!$fill;
$renglon +=1;
if($renglon > 17)
{
$pdf->AddPage();
$pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont('');
$pdf->Cell(0,5,'REPORTE',0,0,'C',1);
$pdf->Ln(10);
$posX = $pdf->GetX() + 112;
$pdf->SetX($posX);
$pdf->Cell(14,5,'Fecha: ','LTRB',0,'C',1);
$pdf->Cell(25,5,$Fecha,'LTRB',0,'C',1);
$pdf->Ln(10);
for($i=0;$i<count($header);$i++)
$pdf->Cell($w[$i],7,$header[$i],1,0,'C',1);
$pdf->Ln();
$renglon = 0;
}
}
if($renglon < 17)
{
for($i=$renglon;$i<=17;$i++)
{
$pdf->Cell($w[0],6,'','LR',0,'C',$fill);
$pdf->Cell($w[1],6,'','LR',0,'C',$fill);
$pdf->Cell($w[2],6,'','LR',0,'C',$fill);
$pdf->Cell($w[3],6,'','LR',0,'L',$fill);
$pdf->Cell($w[4],6,'','LR',0,'L',$fill);
$pdf->Ln();
$fill=!$fill;
}
}
$pdf->Cell(196,0,'','T');
$pdf->Ln(26);

$pdf->Cell(65,6,$P,'',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Cell(65,6,$PieInforme,'LTR',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Ln();

$pdf->SetFont('Arial','',7);
$pdf->Cell(65,6,$Nom,'',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Cell(65,6,'XXXX','LR',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Ln();
$pdf->Cell(65,6,'','',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Cell(65,6,'','LBR',0,'C',0);
$pdf->Ln();
$pdf->SetFont('Arial','',4);
$pdf->Cell(65,6,$cargo . " " . $Area,'',0,'C',0);
$pdf->SetX($pdf->GetX()+1);
$pdf->Cell(65,6,'TTTT','LBR',0,'C',0);
$pdf->Ln();

$pdf->Output();
}
}
class PDF extends FPDF
{
function Header()
{
$this->SetFont('Arial','',12);
$this->Image('Img/logo_salud.jpg',5,10,20,0,'','');
$this->Cell(0,9,'xxx',0,0,'C');
$this->Ln();
$this->SetX($this->GetX()- 8);
$this->Cell(0,9,'xxx',0,0,'C');
$this->Ln();
$this->SetX($this->GetX()- 8);
$this->Cell(0,9,'xxxx',0,0,'C');
$this->Image('Img/logode.jpg',174,10,30,0,'','');
$this->Ln(15);
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$this->Cell(0,10,'xxxxxx',0,0,'L');
$this->SetX(200);
$this->Cell(0,10,'Pagina '.$this->PageNo(),0,0,'R');
}
}
?>

Espero y me puedan orientar....saludos

Última edición por ana86; 05/04/2009 a las 13:09 Razón: Para Mejorar la explicación