Problemas con while en una clase FPDF Hola. Vean yo he creado una clase FPDF para generar una tabla estándar que va a ser llenada por cada registro de la base de datos, pero me sale este error:
Warning: getimagesize(imagenes/proyectos/77_reunion.jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\Archivos de programa\Apache Software Foundation\Apache2.2\htdocs\gt\lib\fpdf\fpdf.php on line 1522
FPDF error: Missing or incorrect image file: imagenes/proyectos/77_reunion.jpg
y esa línea es: Código PHP: function _parsejpg($file) { //Extract info from a JPEG file $a=GetImageSize($file);//Esta es la línea if(!$a) $this->Error('Missing or incorrect image file: '.$file); if($a[2]!=2) $this->Error('Not a JPEG file: '.$file); if(!isset($a['channels']) || $a['channels']==3) $colspace='DeviceRGB'; elseif($a['channels']==4) $colspace='DeviceCMYK'; else $colspace='DeviceGray'; $bpc=isset($a['bits']) ? $a['bits'] : 8; //Read whole file $f=fopen($file,'rb'); $data=''; while(!feof($f)) $data.=fread($f,4096); fclose($f); return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data); }
Y de verdad que no entiendo nada de porque este error ni siquiera entiendo de porque de la librería fpdf.php y para colmo la imágen que hace referencia en el error no se encuentra en mi sitio.
Aqui les va el codigo: Código PHP: include('conexion.php');//Conexión a la BD require('lib/fpdf/fpdf.php'); class PDF_MC_Table extends FPDF { function genera_ficha_tecnica($row) { $w1=244.5; //Ancho de alcance e impacto $w2=71; //Ancho de status, tiempo ejec, avance,... $w3=50; //Ancho de Imágen $h3=80; //Alto de la imágen $h4=5; //Alto de los títulos $h5=20; //Alto de celda tiempo ejec $this->AddPage('L'); $this->SetFont('Arial','B',12); $this->SetTextColor(0,0,153); //Título/Especialista// if (strlen($row["nb_proyecto"]) > 113) $nb_proyecto=strtoupper($row["nb_proyecto"]." (".$row["nb_nombre"]." ".$row["nb_apellido"].")"); else $nb_proyecto=strtoupper($row["nb_proyecto"]."\n"."(".$row["nb_nombre"]." ".$row["nb_apellido"].")"); $this->SetXY(0.5,18); $this->MultiCell($w1+$w3+1,4,$nb_proyecto,0,'C');//Paso la cadena a mayúsculas //$this->Cell(0,4,strtoupper("(".$row["nb_nombre"]." ".$row["nb_apellido"].")"),0,1,'C');//Paso la cadena a mayúsculas //Imágen// $this->Image('imagenes/proyectos/'.$row["nb_imagen"],0.5,28,$w3,$h3); $this->SetX(51.5); //Alcance// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetXY(51.5,28); $this->Cell($w1,$h4,'ALCANCE',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(51.5); $this->Cell($w1,5,$row["tx_alcance"],0,'L'); $this->SetXY(51.5,33); $this->Cell($w1,$h5+$h4+7,'',1,1,''); //Impacto// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY(51.5,66); $this->Cell($w1,$h4,'IMPACTO',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(51); $this->MultiCell($w1,5,$row["tx_impacto"],0,'L'); $this->SetXY(51.5,66); $this->Cell($w1,$h5+$h4+17,'',1,1,''); //Status de la Tecnología// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY(0.6,109); $this->Cell($w2-0.5,$h4,'ESTATUS DE LA TECNOLOGIA',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(0.6); $this->Cell($w2-0.5,$h5,strtoupper($row["tx_status"]),1,1,'CL');//Paso la cadena a mayúsculas //AVANCE PROYECTO// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY($w2+1,109); $this->Cell($w2,$h4,'AVANCE PROYECTO',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX($w2+1); $this->Cell($w2,$h5,'FÍSICO:'.str_replace('.',',',$row["pc_avance_proyecto"]).'%',1,1,'CL'); //TIEMPO EJECUCION// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY(2*($w2+1)-0.5,109); $this->Cell($w2,$h4,'TIEMPO EJECUCION',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(151.5); $this->Ln(); $this->SetX(2*($w2+1)-0.5); $this->Cell($w2,5,'INICIO: '.strtoupper(convert_a_mes_año($row["fe_inicio"])),0,1,'CL'); $this->SetX(2*($w2+1)-0.5); $this->Cell($w2,5,'FIN: '.strtoupper(convert_a_mes_año($row["fe_fin"])),0,1,'CL'); $this->SetXY(2*($w2+1)-0.5,109); $this->Cell($w2,$h5+$h4,'',1,1,''); //PARTICIPANTES// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY(2*($w2+1)+0.3+$w2,109); $this->Cell($w2+10,$h4,'PARTICIPANTES',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(2*($w2+1)-0.7+$w2+1); $this->MultiCell($w2+10,5,strtoupper($row["nb_participantes"]),0,1,'CL'); $this->SetXY(2*($w2+1)+$w2,109); $this->Cell($w2+10,$h5+$h4,'',1,1,''); //SITUACIÓN ACTUAL// $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetFont('','B'); $this->SetXY(0.5,66+$h4+3*$h5+4); $this->Cell($w1+$w3+1,$h4,'SITUACIÓN ACTUAL',1,1,'C',1); $this->SetFillColor(0); $this->SetTextColor(0); $this->SetFont(''); $this->SetX(0.5); $this->SetAutoPageBreak(false,0); $this->MultiCell($w1+$w3+1,5,$row["tx_situacion_actual"],0,'L'); $this->SetXY(0.5,114); $this->Cell($w1+$w3+1,$h5+$h4+64,'',1,1,''); } }
$pdf=new PDF_MC_Table(); $pdf->Open(); $result=mysql_query("SELECT tr004.nb_proyecto, tr004.nb_imagen, tr001.nb_nombre, tr001.nb_apellido, tr004.tx_alcance, tr004.tx_impacto, tr004.tx_status, tr004.pc_avance_proyecto, tr004.fe_inicio, tr004.fe_fin, tr004.nb_participantes, tr004.tx_situacion_actual FROM tr004_proyecto as tr004, tr001_usuario as tr001 WHERE tr001.CO_INDICADOR =tr004.CO_INDICADOR"); if (mysql_num_rows($result)>0) { while ($row = mysql_fetch_array($result)) $pdf->genera_ficha_tecnica($row); } mysql_close(); $pdf->Output();
si yo cambio: Código PHP: while ($row = mysql_fetch_array($result))
por Código PHP: if ($row = mysql_fetch_array($result))
si funciona. Pero no se porque no me funciona con while. Alguna ayuda?
Última edición por joseda_r; 26/12/2007 a las 11:31 |