Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/02/2008, 14:07
Avatar de LuZBinG
LuZBinG
 
Fecha de Ingreso: enero-2008
Mensajes: 407
Antigüedad: 16 años, 3 meses
Puntos: 5
Re: ayuda con cell en FPDF uso de \n

no recuerdo de donde baje la libreria fpdf

voy a poner el codigo donde se crea la tabla es te es el archivo dos.php

Cita:
function Header()
{
//Print the table header if necessary
if($this->ProcessingTable)
$this->TableHeader();
}

function TableHeader()
{

$this->SetFont('TIMES','',11);
$this->SetX($this->TableX);
$fill=!empty($this->HeaderColor);
if($fill)
$this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]);

foreach($this->aCols as $col)

$this->Cell($col['w'],8,$col['c'],1,0,'C',$fill);


$this->Ln();
}

function Row($data)
{
$this->SetX($this->TableX);
$ci=$this->ColorIndex;
$fill=!empty($this->RowColors[$ci]);
if($fill)
$this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
foreach($this->aCols as $col)
$this->Cell($col['w'],5,$data[$col['f']],1,0,$col['a'],$fill);
$this->Ln();
$this->ColorIndex=1-$ci;
}

function CalcWidths($width,$align)
{
//Compute the widths of the columns
$TableWidth=0;
foreach($this->aCols as $i=>$col)
{
$w=$col['w'];
if($w==-1)
$w=$width/count($this->aCols);
elseif(substr($w,-1)=='%')
$w=$w/100*$width;
$this->aCols[$i]['w']=$w;
$TableWidth+=$w;

}
//Compute the abscissa of the table
if($align=='C')
$this->TableX=max(($this->w-$TableWidth)/2,0);
elseif($align=='R')
$this->TableX=max($this->w-$this->rMargin-$TableWidth,0);
else
$this->TableX=$this->lMargin;
}

function AddCol($field=-1,$width=-1,$caption='',$align='L')
{
//Add a column to the table

// $this->SetFont('ARIAL','',12);


if($field==-1)
$field=count($this->aCols);
$this->aCols[]=array('f'=>$field,'c'=>$caption,'w'=>$width,'a'=> $align);


}

function Table($query,$prop=array())
{
//Issue query
$res=mysql_query($query) or die('Error: '.mysql_error()."<BR>Query: $query");
//Add all columns if none was specified
if(count($this->aCols)==0)
{
$nb=mysql_num_fields($res);
for($i=0;$i<$nb;$i++)

$this->AddCol();
}
//Retrieve column names when not specified
foreach($this->aCols as $i=>$col)
{
if($col['c']=='')
{
if(is_string($col['f']))
$this->aCols[$i]['c']=ucfirst($col['f']);
else
$this->aCols[$i]['c']=ucfirst(mysql_field_name($res,$col['f']));

}
}
//Handle properties
if(!isset($prop['width']))
$prop['width']=0;
if($prop['width']==0)
$prop['width']=$this->w-$this->lMargin-$this->rMargin;
if(!isset($prop['align']))
$prop['align']='C';
if(!isset($prop['padding']))
$prop['padding']=$this->cMargin;
$cMargin=$this->cMargin;
$this->cMargin=$prop['padding'];
if(!isset($prop['HeaderColor']))
$prop['HeaderColor']=array();
$this->HeaderColor=$prop['HeaderColor'];
if(!isset($prop['color1']))
$prop['color1']=array();
if(!isset($prop['color2']))
$prop['color2']=array();
$this->RowColors=array($prop['color1'],$prop['color2']);
//Compute column widths
$this->CalcWidths($prop['width'],$prop['align']);
//Print header
$this->TableHeader();
//Print rows
$this->SetFont('TIMES','',9);
$this->ColorIndex=0;
$this->ProcessingTable=true;
while($row=mysql_fetch_array($res))
$this->Row($row);
$this->ProcessingTable=false;
$this->cMargin=$cMargin;
$this->aCols=array();
}




y este es el archivo uno.php donde hago la construccion del pdf

a si

$pdf=new PDF();


$pdf->Open();
Cita:
$pdf->Table('SELECT * FROM total WHERE icve_invoice='.$inv.' ',$prop);

$pdf->WriteHTML("<BR>");
$pdf->AddCol('icve_orden',15,"Order");
$pdf->AddCol('part_num',30,"Part#");

$cabecera = wordwrap( 'Description Service', 11, "\n" ,true );

$pdf->AddCol('descrip',75,$cabecera);
$pdf->AddCol('cantidad',20,"Quantity");
$pdf->AddCol('hr_man',15,"Hrs");
$pdf->AddCol('cost_unit',20,"Unit Cost");
$pdf->AddCol('monto_tot',25,"Total\n Amount");


haber que me sugieres gracias por contestar este scrip esta en la pagina oficial de ahi lo baje
www.fpdf.org


o algo para quitar el foreach que no medeja poner multicell
salu2