Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/12/2015, 17:39
Avatar de emilio_viguri
emilio_viguri
 
Fecha de Ingreso: junio-2011
Ubicación: Mexico
Mensajes: 116
Antigüedad: 12 años, 11 meses
Puntos: 3
Sonrisa Respuesta: imprimir ticket PDF con java

Tu tienes ya una impresora de TICKET ? Yo no la tengo asi que tengo que trabajar al aire por que no tengo como hacer pruebas...

Esto que te paso es para generar un PDF según yo con tamaños ya adecuados, ya funciona y genera el PDF sin problemas pero prueba lo y me pasas ese dato quieres

Código PHP:
Ver original
  1. <?php require("../archivos/fpdf/fpdf.php");?>
  2. <?php
  3. class PDF extends FPDF{
  4.     function FancyTable(){
  5.        
  6.         $this->SetAuthor('Informatica NEXCEN S.A. de C.V.');
  7.         $this->SetCreator('FPDF para www.nexcen.com.mx');
  8.         $this->SetSubject('www.nexcen.com.mx');
  9.         $this->SetKeywords("VENTA ");
  10.        
  11.         #Al parecer en ticket tiene como máximo de Px 70 pero hay que checar margenes.
  12.        
  13.         $X=1; $Y=2; #Inicio de lugar para la marca o margen celda.     
  14.         $grosor = 70; #ancho del tiket.
  15.         $LogoTamano = 20;
  16.         $SaltoLinea = 4;
  17.        
  18.         $this->SetXY($X,$Y);
  19.         $this->Cell($grosor, 270, '', 1); #Celda Margen
  20.        
  21.         #LOGO Seleccionar el logo a mostrar.
  22.         $this->Image("../archivos/imagenes/logo.jpg",23,$Y+1,$LogoTamano);
  23.        
  24.         #Iniciamos Escritura en celdas.
  25.         $this->SetXY($X, $Y+$LogoTamano);
  26.         $this->SetFont('Arial','B',9);
  27.         $this->SetTextColor(0,0,0);
  28.         $this->Write(0,'Venta #');
  29.         $this->Ln($SaltoLinea); $this->SetX($X);
  30.         $this->Write(0,'Tipo de Venta');
  31.         $this->Ln($SaltoLinea); $this->SetX($X);
  32.         $this->Write(0,'Fecha {venta.fecha}');
  33.         $this->Ln($SaltoLinea); $this->SetX($X);
  34.         $this->Write(0,'Sucursal {venta.almacen}');
  35.         $this->Ln($SaltoLinea); $this->SetX($X);
  36.         $this->Write(0,'Cliente {venta.nombre}');
  37.         $this->Ln($SaltoLinea); $this->SetX($X);
  38.        
  39.         $this->Rect($X,$LogoTamano+21,$grosor,0); #Dibuja un rectángulo.
  40.                
  41.         #Crear Encabezado de Celdas
  42.         $this->SetFont('Arial','B',8);
  43.         $Border = 0; #1 Si 0 No.
  44.         $w=array(10,12,12,9,13,14); #tamaño de las celdas
  45.         $titulocolumna=array('CANT','PROD','UNID','T/E','COSTO','');
  46.         for($i=0; $i<=count($titulocolumna)-1; $i++)
  47.             $this->Cell($w[$i],5,$titulocolumna[$i],$Border,0,'C',0);
  48.         $this->Ln();
  49.         $this->SetX($X);
  50.        
  51.         $this->SetFont('Arial','',9);
  52.        
  53. #       do{
  54.         for($i=0; $i<=rand(1,41); $i++){
  55.             $this->Cell($w[0],5,$i+1,$Border,0,'C',0);
  56.             $this->Cell($w[1],5,rand(1,2015),$Border,0,'C',0);
  57.             $this->Cell($w[2],5,rand(1,2015),$Border,0,'C',0);
  58.             $this->Cell($w[3],5,rand(1,2015),$Border,0,'C',0);
  59.             $this->Cell($w[4],5,rand(1,2015),$Border,0,'R',0);
  60.             $this->Cell($w[5],5,rand(1,2015),$Border,0,'R',0);
  61.             $this->Ln($SaltoLinea+1);
  62.             $this->SetX($X);
  63.         }#while
  64.            
  65.         $this->Cell($w[0],5,'CatTot',$Border,0,'C',0);
  66.         $this->Cell($w[1],5,'',$Border,0,'C',0);
  67.         $this->Cell($w[2],5,'',$Border,0,'C',0);
  68.         $this->Cell($w[3],5,'',$Border,0,'C',0);
  69.         $this->Cell($w[4],5,'',$Border,0,'R',0);
  70.         $this->Cell($w[5],5,'CatTot',$Border,0,'C',0);
  71.         $this->Ln($SaltoLinea+1);
  72.         $this->SetX($X);
  73.        
  74.         $this->MultiCell($grosor,4,'T/E = Tipo de Entrega.',$Border,'l');
  75.         $this->SetX($X);
  76.         $this->MultiCell($grosor,4,'RE = Requiere Entrega.',$Border,'l');
  77.         $this->SetX($X);
  78.         $this->MultiCell($grosor,4,'RA = Recoger en Almacen.',$Border,'l');
  79.     }
  80. }
  81.  
  82. //Creación del objeto de la clase heredada
  83. $pdf=new PDF();
  84. $pdf->AliasNbPages();
  85. $pdf->AddPage();
  86. $pdf->FancyTable();
  87. $pdf->Output();
  88. ?>

Si requiere algún arreglo me avisas y ya se los hago

Recuerda agregar la librería de FPDF aqui la descargas FPDF Version: 1.6