Foros del Web » Programando para Internet » PHP »

[Ayuda]Imprimir imagen en celda del fpdf

Estas en el tema de [Ayuda]Imprimir imagen en celda del fpdf en el foro de PHP en Foros del Web. Buen dia! Estoy haciendo un reporte en fpdf el cual consiste imprimir un listado de productos con sus respectivas imágenes pero no me esta apareciendo ...
  #1 (permalink)  
Antiguo 19/10/2011, 15:36
 
Fecha de Ingreso: mayo-2010
Mensajes: 60
Antigüedad: 13 años, 11 meses
Puntos: 0
[Ayuda]Imprimir imagen en celda del fpdf

Buen dia!

Estoy haciendo un reporte en fpdf el cual consiste imprimir un listado de productos con sus respectivas imágenes pero no me esta apareciendo las imágenes en la celda que debe de salir... Sino antes de la impresión de los resultados... Les anexo unos screen shot para que puedan ver la linea de código y como me sale el reporte...

[URL=http://imageshack.us/photo/my-images/695/imagendch.jpg/][IMG]http://img695.imageshack.us/img695/82/imagendch.jpg[/img][/URL]

[URL=http://imageshack.us/photo/my-images/718/imagen2wq.jpg/][IMG]http://img718.imageshack.us/img718/5264/imagen2wq.jpg[/img][/URL]
  #2 (permalink)  
Antiguo 20/10/2011, 00:57
 
Fecha de Ingreso: octubre-2011
Mensajes: 13
Antigüedad: 12 años, 6 meses
Puntos: 2
Respuesta: [Ayuda]Imprimir imagen en celda del fpdf

Y porque no montas mejor un template HTML y ahí dentro montas todo, creo que es más fácil de trabajar FPDF en esos casos.
  #3 (permalink)  
Antiguo 20/10/2011, 00:58
 
Fecha de Ingreso: octubre-2011
Mensajes: 13
Antigüedad: 12 años, 6 meses
Puntos: 2
Respuesta: [Ayuda]Imprimir imagen en celda del fpdf

Fíjate acá http://html2pdf.seven49.net/ y verás muchos ejemplos de como puedes montarlo usando HTML con fpdf.
  #4 (permalink)  
Antiguo 20/10/2011, 08:01
 
Fecha de Ingreso: mayo-2010
Mensajes: 60
Antigüedad: 13 años, 11 meses
Puntos: 0
Respuesta: [Ayuda]Imprimir imagen en celda del fpdf

Amigos tendro otro inconveniente... Que es al finalizar la pagina me imprime la imagen fuera de la celda. Pueden ver el error en la siguiente imagen...

[URL=http://imageshack.us/photo/my-images/842/errrorfdpf.jpg/][IMG]http://img842.imageshack.us/img842/7210/errrorfdpf.jpg[/IMG][/URL]

Aca el código del reporte en fpdf

Código:
<?php
include('config_reportes.php');
include('fpdf.php');
include('../../menu_sistemas/lib/common.php');

class PDF extends FPDF {
    public $title;
    public $conexion;
    public $datosgenerales;
    public $array_compra;
	
    function Header() {
		$this->SetY(15);
        $width = 10;

        $this->Image('../imagenes/logo_gps.png',10,5,30);


        $this->SetY(5);
        $this->SetFont('Arial','',6);
        //$this->SetFillColor(239,239,239);
        $this->SetFont('Arial','B',6);
        $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["nombre_empresa"]),0,0,'C');
        $this->Ln(3);
        $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["direccion"]),0,0,'C');
        $this->Ln(3);
        $this->Cell(0,0, "Telefonos: ".$this->datosgenerales[0]["telefonos"] ,0,0,'C');
        $this->Ln(3);
        $this->Cell(0,0, "RIF ".utf8_decode($this->datosgenerales[0]["rif"]),0,0,'C');
		
        $this->Cell(0,0, utf8_decode("Fecha de Creación: ".fecha($this->array_compra[0]["fechacompra"])),0,0,'R');
        $this->Ln(3);
  

        $this->SetFont('Arial','',8);
        $this->Cell(0,0, utf8_decode("Nro. Cotización: ".$this->array_compra[0]["cod_compra"]),0,0,'R');
        $this->Ln(12);
        $this->SetX(10);
        $this->SetFont('Arial','',6);
	
        $this->Cell(0,0, "Proveedor: ".utf8_decode($this->array_compra[0]["nproveedor"]),0,0,'L');
        $this->Ln(3);
        $this->SetX(10);
        $this->Cell(0,0, utf8_decode("Dirección: ".$this->array_compra[0]["direccionproveedor"]),0,0,'L');
        $this->Ln(3);
        $this->SetX(10);
        $this->Cell(0,0, utf8_decode("Telefonos: ".$this->array_compra[0]["telefonosproveedor"]),0,0,'L');
        $this->Ln(6);

       /* $this->SetX(10);
        $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["id_fiscal2"].": ".$this->array_compra[0]["nitproveedor"]),0,0,'L');
        $this->Ln(3);
	  */
	   $this->Ln(3);
        /*$this->SetX(10);
        $this->Cell(0,0, utf8_decode("Reponsable: ".$this->array_compra[0]["responsable"]),0,0,'L');
        $this->Ln(3);
*/
       /* $this->SetX(14);
        $this->Cell(0,0, utf8_decode("Fac. Nro de Compra: ".$this->array_compra[0]["num_factura_compra"]),0,0,'L');
        $this->Ln(3);
	*/
        $this->SetX(14);
        $this->SetFont('Arial','B',12);
        $this->Cell(0,0, utf8_decode("COTIZACIÓN"),0,0,'C');
        $this->Ln(6);

        


        $this->SetLeftMargin(50);
        $width = 5;
        $this->SetX(10);
        $this->SetFont('Arial','',6);
		
		
        $this->SetFillColor(10,10,10,10,10,10,10,10,10);
        $this->Cell(11,$width,'Codigo',1,0,"C",0);
        $this->Cell(60,$width,utf8_decode('Descripción'),1,0,"C",0);
		 $this->Cell(30,$width,utf8_decode('Imagen'),1,0,"C",0);
        $this->Cell(11,$width,utf8_decode('Cantidad'),1,0,"C",0);
        $this->Cell(15,$width,utf8_decode('Precio'),1,0,"C",0);
        //$this->Cell(20,$width,utf8_decode('Almacen'),1,0,"C",0);
        $this->Cell(15,$width,utf8_decode('I.V.A'),1,0,"C",0);
        $this->Cell(20,$width,utf8_decode('Total Sin I.V.A'),1,0,"R",0);
        $this->Cell(11,$width,utf8_decode('% I.V.A'),1,0,"R",0);
        $this->Cell(20,$width,utf8_decode('Total con I.V.A'),1,0,"R",0);
        $this->Ln(5);


    }

    function Footer() {
        $this->SetY(-15);
		$this->SetX(10);
        $this->SetFont('Arial','I',10);

        $this->Cell(0,10,utf8_decode('Página ').$this->PageNo(),0,0,'C');
    }

    function dwawCell($title,$data) {
        $width = 8;
        $this->SetFont('Arial','B',12);
        $y =  $this->getY() * 20;
        $x =  $this->getX();
        $this->SetFillColor(206,230,100);
        $this->MultiCell(175,8,$title,0,1,'L',0);
        $this->SetY($y);
        $this->SetFont('Arial','',12);
        $this->SetFillColor(206,230,172);
        $w=$this->GetStringWidth($title)+3;
        $this->SetX($x+$w);
        $this->SetFillColor(206,230,172);
        $this->MultiCell(175,8,$data,0,1,'J',0);

    }


    function ChapterBody() {



        //$conn = new rp_Connect();
        //$conn->SQL("select * from esquema.almacen_ubicacion");





        $this->SetWidths(array(11,60,30,11,15,15,20,11,20));
		
        $this->SetAligns(array("C","J","C","C","C","R","R","R","R"));
        $this->SetFillColor(232,232,232,232,232,232,232,232,232);
        $cantidaditems = $this->array_compra[0]["cantidad_items"];

        $subtotal = 0;
        for($i=0;$i<$cantidaditems;$i++) {
            $this->SetLeftMargin(30);
            $width = 5;
            $this->SetX(10);
			//this->getY() ;
			//$this->SetY($y);
            $this->SetFont('Arial','',6);
			$imagen = '../imagenes/'.$this->array_compra[$i]["foto"];
            $subtotal += $this->array_compra[$i]["_item_cantidad"]*$this->array_compra[$i]["_item_preciosiniva"];
			
            $this->Row(
			
                    array(  $this->array_compra[$i]["cod_item"],
                    utf8_decode($this->array_compra[$i]["descripcion1"]),
					//$this->Cell( 1, 1, $this->Image('../imagenes/'.$this->array_compra[$i]["foto"],90,$this->GetY(),'LR',0,null,null), 0, 0, 'L', false ),
					//$this->Cell(16,16,$this->Image($imagen,90,$this->GetY(),16,16)),
					$this->Image($imagen,90,$this->GetY(),16,16,null,null),
                    $this->array_compra[$i]["_item_cantidad"],
                    number_format($this->array_compra[$i]["_item_preciosiniva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
                    //$this->array_compra[$i]["descripcion"],
                    number_format($this->array_compra[$i]["_tiva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
                    number_format($this->array_compra[$i]["_item_totalsiniva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
                    number_format($this->array_compra[$i]["piva"], 2, ',', '.')." %",
                    number_format($this->array_compra[$i]["_item_totalconiva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"]),1);

        }

        $this->Ln(2);
        //$this->SetLeftMargin(50);
        $width = 5;
        $this->SetX(168);
        $this->SetFont('Arial','',6);
        $this->Cell(15,$width,utf8_decode('Sub-Total'),1,0,"R",0);
        $this->Cell(20,$width,number_format($subtotal, 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
        $this->Ln(5);
        $this->SetX(168);
        $this->Cell(15,$width,utf8_decode('I.V.A'),1,0,"R",0);
        $this->Cell(20,$width,number_format($this->array_compra[0]["ivaTotalcompra"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
        $this->Ln(5);
        $this->SetX(168);
        $this->Cell(15,$width,utf8_decode('Total'),1,0,"R",0);
        $this->Cell(20,$width,number_format($this->array_compra[0]["TotalTotalcompra"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
        $this->Ln(5);



    }

    function ChapterTitle($num,$label) {
        $this->SetFont('Arial','',10);
        $this->SetFillColor(200,220,255);
        $this->Cell(0,6,"$label",0,1,'L',1);
        $this->Ln(8);
    }

    function SetTitle($title) {
        $this->title   = $title;
    }

    function PrintChapter() {

        $this->AddPage();

        $this->ChapterBody();
    }

    function DatosGenerales($array) {

		$this->Cell(10,10,"$label",0,1,'L',1,true);
        $this->datosgenerales = $array;
		$this->getY() * 40;
	    $this->SetY($y);
		;
    }

    function Arraycompra($array) {
        $this->array_compra = $array;
    }


}


$nro_compra = @$_GET["codigo"];
$comunes = new ConexionComun();

$array_parametros_generales = $comunes->ObtenerFilasBySqlSelect("select * from parametros_generales");

$array_compra =   $comunes->ObtenerFilasBySqlSelect("
SELECT *, p.descripcion as nproveedor,
p.direccion as direccionproveedor,
p.telefonos as telefonosproveedor,
p.nit as nitproveedor
from  compra c  inner join compra_detalle cd on cd.id_compra = c.id_compra
    inner join proveedores p on p.id_proveedor = c.id_proveedor
    left join almacen a on a.cod_almacen = cd._item_almacen inner join
    item i on i.id_item = cd.id_item
    where c.cod_compra = '".$nro_compra."'");




if(count($array_compra)==0){
    echo "no se encontraron registros.";
    exit;
}

$pdf=new PDF('L','mm','letter');
$title='Detalle de Cotizacion';
$pdf->DatosGenerales($array_parametros_generales);
$pdf->Arraycompra($array_compra);

$pdf->SetTitle($title);
$pdf->PrintChapter();
$pdf->SetDisplayMode('default');
$pdf->Output();

?>

Etiquetas: celda, fpdf
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 09:49.