Jump to content


Photo

[Ayuda]Imprimir imagen en celda del fpdf


  • Please log in to reply
No replies to this topic

#1 jh0sz

jh0sz

    Newbie

  • Miembros
  • Pip
  • 2 posts

Posted 20 October 2011 - 01:13 PM

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

[noparse]Imagen Enviada[/noparse]

Aca el código del reporte en fpdf



delphi
  1. <?php
  2. include('config_reportes.php');
  3. include('fpdf.php');
  4. include('../../menu_sistemas/lib/common.php');
  5.  
  6. class PDF extends FPDF {
  7.     public $title;
  8.     public $conexion;
  9.     public $datosgenerales;
  10.     public $array_compra;
  11.  
  12.     function Header() {
  13. $this->SetY(15);
  14.         $width = 10;
  15.  
  16.         $this->Image('../imagenes/logo_gps.png',10,5,30);
  17.  
  18.  
  19.         $this->SetY(5);
  20.         $this->SetFont('Arial','',6);
  21.         //$this->SetFillColor(239,239,239);
  22.         $this->SetFont('Arial','B',6);
  23.         $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["nombre_empresa"]),0,0,'C');
  24.         $this->Ln(3);
  25.         $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["direccion"]),0,0,'C');
  26.         $this->Ln(3);
  27.         $this->Cell(0,0, "Telefonos: ".$this->datosgenerales[0]["telefonos"] ,0,0,'C');
  28.         $this->Ln(3);
  29.         $this->Cell(0,0, "RIF ".utf8_decode($this->datosgenerales[0]["rif"]),0,0,'C');
  30.  
  31.         $this->Cell(0,0, utf8_decode("Fecha de Creación: ".fecha($this->array_compra[0]["fechacompra"])),0,0,'R');
  32.         $this->Ln(3);
  33.  
  34.  
  35.         $this->SetFont('Arial','',8);
  36.         $this->Cell(0,0, utf8_decode("Nro. Cotización: ".$this->array_compra[0]["cod_compra"]),0,0,'R');
  37.         $this->Ln(12);
  38.         $this->SetX(10);
  39.         $this->SetFont('Arial','',6);
  40.  
  41.         $this->Cell(0,0, "Proveedor: ".utf8_decode($this->array_compra[0]["nproveedor"]),0,0,'L');
  42.         $this->Ln(3);
  43.         $this->SetX(10);
  44.         $this->Cell(0,0, utf8_decode("Dirección: ".$this->array_compra[0]["direccionproveedor"]),0,0,'L');
  45.         $this->Ln(3);
  46.         $this->SetX(10);
  47.         $this->Cell(0,0, utf8_decode("Telefonos: ".$this->array_compra[0]["telefonosproveedor"]),0,0,'L');
  48.         $this->Ln(6);
  49.  
  50.       /* $this->SetX(10);
  51.         $this->Cell(0,0, utf8_decode($this->datosgenerales[0]["id_fiscal2"].": ".$this->array_compra[0]["nitproveedor"]),0,0,'L');
  52.         $this->Ln(3);
  53.   */
  54.   $this->Ln(3);
  55.         /*$this->SetX(10);
  56.         $this->Cell(0,0, utf8_decode("Reponsable: ".$this->array_compra[0]["responsable"]),0,0,'L');
  57.         $this->Ln(3);
  58. */
  59.       /* $this->SetX(14);
  60.         $this->Cell(0,0, utf8_decode("Fac. Nro de Compra: ".$this->array_compra[0]["num_factura_compra"]),0,0,'L');
  61.         $this->Ln(3);
  62. */
  63.         $this->SetX(14);
  64.         $this->SetFont('Arial','B',12);
  65.         $this->Cell(0,0, utf8_decode("COTIZACIÓN"),0,0,'C');
  66.         $this->Ln(6);
  67.  
  68.        
  69.  
  70.  
  71.         $this->SetLeftMargin(50);
  72.         $width = 5;
  73.         $this->SetX(10);
  74.         $this->SetFont('Arial','',6);
  75.  
  76.  
  77.         $this->SetFillColor(10,10,10,10,10,10,10,10,10);
  78.         $this->Cell(11,$width,'Codigo',1,0,"C",0);
  79.         $this->Cell(60,$width,utf8_decode('Descripción'),1,0,"C",0);
  80. $this->Cell(30,$width,utf8_decode('Imagen'),1,0,"C",0);
  81.         $this->Cell(11,$width,utf8_decode('Cantidad'),1,0,"C",0);
  82.         $this->Cell(15,$width,utf8_decode('Precio'),1,0,"C",0);
  83.         //$this->Cell(20,$width,utf8_decode('Almacen'),1,0,"C",0);
  84.         $this->Cell(15,$width,utf8_decode('I.V.A'),1,0,"C",0);
  85.         $this->Cell(20,$width,utf8_decode('Total Sin I.V.A'),1,0,"R",0);
  86.         $this->Cell(11,$width,utf8_decode('% I.V.A'),1,0,"R",0);
  87.         $this->Cell(20,$width,utf8_decode('Total con I.V.A'),1,0,"R",0);
  88.         $this->Ln(5);
  89.  
  90.  
  91.     }
  92.  
  93.     function Footer() {
  94.         $this->SetY(-15);
  95. $this->SetX(10);
  96.         $this->SetFont('Arial','I',10);
  97.  
  98.         $this->Cell(0,10,utf8_decode('Página ').$this->PageNo(),0,0,'C');
  99.     }
  100.  
  101.     function dwawCell($title,$data) {
  102.         $width = 8;
  103.         $this->SetFont('Arial','B',12);
  104.         $y =  $this->getY() * 20;
  105.         $x =  $this->getX();
  106.         $this->SetFillColor(206,230,100);
  107.         $this->MultiCell(175,8,$title,0,1,'L',0);
  108.         $this->SetY($y);
  109.         $this->SetFont('Arial','',12);
  110.         $this->SetFillColor(206,230,172);
  111.         $w=$this->GetStringWidth($title)+3;
  112.         $this->SetX($x+$w);
  113.         $this->SetFillColor(206,230,172);
  114.         $this->MultiCell(175,8,$data,0,1,'J',0);
  115.  
  116.     }
  117.  
  118.  
  119.     function ChapterBody() {
  120.  
  121.  
  122.  
  123.         //$conn = new rp_Connect();
  124.         //$conn->SQL("select * from esquema.almacen_ubicacion");
  125.  
  126.  
  127.  
  128.  
  129.  
  130.         $this->SetWidths(array(11,60,30,11,15,15,20,11,20));
  131.  
  132.         $this->SetAligns(array("C","J","C","C","C","R","R","R","R"));
  133.         $this->SetFillColor(232,232,232,232,232,232,232,232,232);
  134.         $cantidaditems = $this->array_compra[0]["cantidad_items"];
  135.  
  136.         $subtotal = 0;
  137.         for($i=0;$i<$cantidaditems;$i++) {
  138.             $this->SetLeftMargin(30);
  139.             $width = 5;
  140.             $this->SetX(10);
  141. //this->getY() ;
  142. //$this->SetY($y);
  143.             $this->SetFont('Arial','',6);
  144. $imagen = '../imagenes/'.$this->array_compra[$i]["foto"];
  145.             $subtotal += $this->array_compra[$i]["_item_cantidad"]*$this->array_compra[$i]["_item_preciosiniva"];
  146.  
  147.             $this->Row(
  148.  
  149.                     array(  $this->array_compra[$i]["cod_item"],
  150.                     utf8_decode($this->array_compra[$i]["descripcion1"]),
  151. //$this->Cell( 1, 1, $this->Image('../imagenes/'.$this->array_compra[$i]["foto"],90,$this->GetY(),'LR',0,null,null), 0, 0, 'L', false ),
  152. //$this->Cell(16,16,$this->Image($imagen,90,$this->GetY(),16,16)),
  153. $this->Image($imagen,90,$this->GetY(),16,16,null,null),
  154.                     $this->array_compra[$i]["_item_cantidad"],
  155.                     number_format($this->array_compra[$i]["_item_preciosiniva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
  156.                     //$this->array_compra[$i]["descripcion"],
  157.                     number_format($this->array_compra[$i]["_tiva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
  158.                     number_format($this->array_compra[$i]["_item_totalsiniva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],
  159.                     number_format($this->array_compra[$i]["piva"], 2, ',', '.')." %",
  160.                     number_format($this->array_compra[$i]["_item_totalconiva"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"]),1);
  161.  
  162.         }
  163.  
  164.         $this->Ln(2);
  165.         //$this->SetLeftMargin(50);
  166.         $width = 5;
  167.         $this->SetX(168);
  168.         $this->SetFont('Arial','',6);
  169.         $this->Cell(15,$width,utf8_decode('Sub-Total'),1,0,"R",0);
  170.         $this->Cell(20,$width,number_format($subtotal, 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
  171.         $this->Ln(5);
  172.         $this->SetX(168);
  173.         $this->Cell(15,$width,utf8_decode('I.V.A'),1,0,"R",0);
  174.         $this->Cell(20,$width,number_format($this->array_compra[0]["ivaTotalcompra"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
  175.         $this->Ln(5);
  176.         $this->SetX(168);
  177.         $this->Cell(15,$width,utf8_decode('Total'),1,0,"R",0);
  178.         $this->Cell(20,$width,number_format($this->array_compra[0]["TotalTotalcompra"], 2, ',', '.')." ".$this->datosgenerales[0]["moneda"],1,0,"R",0);
  179.         $this->Ln(5);
  180.  
  181.  
  182.  
  183.     }
  184.  
  185.     function ChapterTitle($num,$label) {
  186.         $this->SetFont('Arial','',10);
  187.         $this->SetFillColor(200,220,255);
  188.         $this->Cell(0,6,"$label",0,1,'L',1);
  189.         $this->Ln(8);
  190.     }
  191.  
  192.     function SetTitle($title) {
  193.         $this->title  = $title;
  194.     }
  195.  
  196.     function PrintChapter() {
  197.  
  198.         $this->AddPage();
  199.  
  200.         $this->ChapterBody();
  201.     }
  202.  
  203.     function DatosGenerales($array) {
  204.  
  205. $this->Cell(10,10,"$label",0,1,'L',1,true);
  206.         $this->datosgenerales = $array;
  207. $this->getY() * 40;
  208.     $this->SetY($y);
  209. ;
  210.     }
  211.  
  212.     function Arraycompra($array) {
  213.         $this->array_compra = $array;
  214.     }
  215.  
  216.  
  217. }
  218.  
  219.  
  220. $nro_compra = @$_GET["codigo"];
  221. $comunes = new ConexionComun();
  222.  
  223. $array_parametros_generales = $comunes->ObtenerFilasBySqlSelect("select * from parametros_generales");
  224.  
  225. $array_compra =  $comunes->ObtenerFilasBySqlSelect("
  226. SELECT *, p.descripcion as nproveedor,
  227. p.direccion as direccionproveedor,
  228. p.telefonos as telefonosproveedor,
  229. p.nit as nitproveedor
  230. from  compra c  inner join compra_detalle cd on cd.id_compra = c.id_compra
  231.     inner join proveedores p on p.id_proveedor = c.id_proveedor
  232.     left join almacen a on a.cod_almacen = cd._item_almacen inner join
  233.     item i on i.id_item = cd.id_item
  234.     where c.cod_compra = '".$nro_compra."'");
  235.  
  236.  
  237.  
  238.  
  239. if(count($array_compra)==0){
  240.     echo "no se encontraron registros.";
  241.     exit;
  242. }
  243.  
  244. $pdf=new PDF('L','mm','letter');
  245. $title='Detalle de Cotizacion';
  246. $pdf->DatosGenerales($array_parametros_generales);
  247. $pdf->Arraycompra($array_compra);
  248.  
  249. $pdf->SetTitle($title);
  250. $pdf->PrintChapter();
  251. $pdf->SetDisplayMode('default');
  252. $pdf->Output();
  253.  
  254. ?>


  • 0




IP.Board spam blocked by CleanTalk.