Buenas foro
Tengo un problema al tratar de crear una tabla con la librería FPDF.
Pero al tratar de hacer la tabla me arroja el ciclo pero en errores.
así esta el archivo para hacer la tabla:
Código PHP:
Ver original<?php
require('fpdf.php');
class PDF_MC_Table extends FPDF
{
var $widths;
var $aligns;
function SetWidths($w)
{
//Set the array of column widths
$this->widths=$w;
}
function SetAligns($a)
{
//Set the array of column alignments
$this->aligns=$a;
}
function Row($data)
{
//Calculate the height of the row
$nb=0;
for($i=0;$i<count($data);$i++) $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i])); $h=5*$nb;
//Issue a page break first if needed
$this->CheckPageBreak($h);
//Draw the cells of the row
for($i=0;$i<count($data);$i++) {
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ?
$this->aligns[$i] : 'L'; //Save the current position
$x=$this->GetX();
$y=$this->GetY();
//Draw the border
$this->Rect($x,$y,$w,$h);
//Print the text
$this->MultiCell($w,5,$data[$i],0,$a);
//Put the position to the right of the cell
$this->SetXY($x+$w,$y);
}
//Go to the next line
$this->Ln($h);
}
function CheckPageBreak($h)
{
//If the height h would cause an overflow, add a new page immediately
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}
function NbLines($w,$txt)
{
//Computes the number of lines a MultiCell of width w will take
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
}
?>
Y este es el que hace el pdf:
Código PHP:
Ver originalheader ('Content-type: text/html; charset=utf-8'); require('../../libs/fpdf/PDF_MC_Table.php'); // tiene el require de fpdf.
class PDF extends FPDF
{
//Encabezado de pagina
{
$this->Image('../../imagenes/banner_pedidos.jpg',5,5,285,35,'JPG');
$this->Cell(200,35,"","",1,'C');
}
function Footer()
{
$this->SetFont('Arial','B',10);
$this->SetY(-20);
$this->SetFont('Arial','I',12);
$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,1,'C');
}
}
$pdf=new PDF('L','mm','A4');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Ln(5);
$pdf->Ln(5);
$pdf->SetFont('Arial','',12);
$pdf->SetTextColor(115,115,115);
$pdf->SetFillColor(237,237,237);
$pdf->SetDrawColor(215,215,215);
$pdf->SetLineWidth(.1);
$pdf->Cell(20,7,'Cantidad',"BRLT",0,'C',true);
$pdf->Cell(117,7,' Producto | Servicio',"BRLT",0,'L',true);
$pdf->Cell(5,7,'P',"BRLT",0,'C',true);
$pdf->Cell(5,7,"D","BRLT",0,'C',true);
$pdf->Cell(5,7,"I","BRLT",0,'C',true);
$pdf->Cell(30,7,"$ Precio U.","BRLT",0,'C',true);
$pdf->Cell(30,7,"$ Importe","BRLT",0,'C',true);
$pdf->Cell(63,7,"Observaciones","BRLT",1,'C',true);
$pdf->Ln(1);
$pdf->SetFont('Arial','',11);
$dgral = $ped->productosDetalle($_GET['dt']);
$contador = 0;
$mc_table = new PDF_MC_Table();
$mc_table->SetWidths(array(20,117,5,5,5,30,30,63)); for($i=0;$i<1;$i++):
$mc_table->Row(array("Cantidad","Descripcion","P","D","I","Precio","Importe","Observaciones")); endfor;
Esto me regresa:
Código texto:
Ver originalWarning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php on line 62
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php on line 62
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php on line 62
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php on line 62
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php on line 62
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Division by zero in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 700
Warning: Cannot modify header information - headers already sent by (output started at /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/PDF_MC_Table.php:62) in /home/iconogra/public_html/sistema/server_pruebas/libs/fpdf/fpdf.php on line 1017
FPDF error: Some data has already been output, can't send PDF file
Alguien me puede apoyar.
Se los agradecería mucho la vdd