Foros del Web » Programación para mayores de 30 ;) » Java »

impresion y diseño de etiquetas

Estas en el tema de impresion y diseño de etiquetas en el foro de Java en Foros del Web. tengo el siguiente codigo en el cual diseño una etiqueta de 3.3 X 3.2 pulgadas y se imprime mi problema esta en q necesito poner ...
  #1 (permalink)  
Antiguo 03/02/2011, 11:03
Avatar de valdo_kof  
Fecha de Ingreso: noviembre-2009
Ubicación: San Juan del Rio, Qro
Mensajes: 192
Antigüedad: 14 años, 5 meses
Puntos: 16
impresion y diseño de etiquetas

tengo el siguiente codigo en el cual diseño una etiqueta de 3.3 X 3.2 pulgadas y se imprime mi problema esta en q necesito poner o girar 90 grados mi variable julian y serial y colocarla igual como coloco todos mis datos en la etiqueta si alguien puede ayudarme se los agradecere infinitamente

les dejo mi codigo para quien pueda servirle:



Código Java:
Ver original
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.FontMetrics;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.geom.Rectangle2D;
  7. import java.awt.image.BufferedImage;
  8. import java.awt.print.Book;
  9. import java.awt.print.PageFormat;
  10. import java.awt.print.Printable;
  11. import java.awt.print.PrinterJob;
  12. import java.util.logging.Level;
  13. import java.util.logging.Logger;
  14. import net.sourceforge.barbecue.Barcode;
  15. import net.sourceforge.barbecue.BarcodeException;
  16. import net.sourceforge.barbecue.BarcodeFactory;
  17. import net.sourceforge.barbecue.BarcodeImageHandler;
  18. import net.sourceforge.barbecue.output.OutputException;
  19.  
  20. public class JavaWorldPrintExample3 {
  21.  public static void main(String[] args) {
  22.     JavaWorldPrintExample3 example3 = new JavaWorldPrintExample3();
  23.     System.exit(0);
  24.   }
  25.  private final static int POINTS_PER_INCH = 72;
  26.  public JavaWorldPrintExample3() {
  27.   PrinterJob printJob = PrinterJob.getPrinterJob();
  28.   Book book = new Book();
  29.   book.append(new IntroPage(), printJob.defaultPage());
  30.     printJob.setPageable(book);
  31.     if (printJob.printDialog()) {
  32.       try {
  33.         printJob.print();
  34.       } catch (Exception PrintException) {
  35.         PrintException.printStackTrace();
  36.       }
  37.     }
  38.   }
  39.   private class IntroPage implements Printable {
  40.      
  41.          public int print(Graphics g, PageFormat pageFormat, int page) {
  42.             try {
  43.          
  44.                 Graphics2D g2d = (Graphics2D) g;
  45.                 Graphics2D g2d2 = (Graphics2D) g;
  46.                 g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
  47.                 g2d.setPaint(Color.black);
  48.                 Rectangle2D.Double rec_item = new Rectangle2D.Double(1, 1, 227, 84);
  49.                 Rectangle2D.Double rec_q = new Rectangle2D.Double(1, 85, 227, 56);
  50.                 Rectangle2D.Double rec_l = new Rectangle2D.Double(1, 141, 227, 56);
  51.                 Rectangle2D.Double rec_c = new Rectangle2D.Double(1, 197, 227, 30);
  52.                 g2d.draw(rec_item);
  53.                 g2d.draw(rec_q);
  54.                 g2d.draw(rec_l);
  55.                 g2d.draw(rec_c);
  56.                 String country = "HARADA INDUSTRY OF AMERICA";
  57.                 Font countryFont = new Font("Arial", Font.BOLD, 8);
  58.                 String item = "ITEM No.";
  59.                 Font itemFont = new Font("Arial", Font.BOLD, 6);
  60.                 String n = "(N)";
  61.                 Font nFont = new Font("Arial", Font.BOLD, 6);
  62.                 String itemn = "16U-24130-02";
  63.                 Font itemnFont = new Font("Arial", Font.BOLD, 14);
  64.                 Barcode barcode = BarcodeFactory.createCode39("N16U-24130-02", false);
  65.                 barcode.setDrawingText(false);
  66.                 barcode.setBarHeight(45);
  67.                 barcode.setBarWidth(1);
  68.                 BufferedImage image = BarcodeImageHandler.getImage(barcode);
  69.                 //////
  70.                String quality = "QUALITY";
  71.                 Font qualityFont = new Font("Arial", Font.BOLD, 6);
  72.                 String q = "(Q)";
  73.                 Font qFont = new Font("Arial", Font.BOLD, 6);
  74.                 String qtyn = "50";
  75.                 Font qtyFont = new Font("Arial", Font.BOLD, 14);
  76.                 Barcode barcodeqty = BarcodeFactory.createCode39("Q50", false);
  77.                 barcodeqty.setDrawingText(false);
  78.                 barcodeqty.setBarHeight(42);
  79.                 barcodeqty.setBarWidth(1);
  80.                 BufferedImage imageqty = BarcodeImageHandler.getImage(barcodeqty);
  81.                 ///////////////
  82.                  String lote = "Lot No.";
  83.                 Font loteFont = new Font("Arial", Font.BOLD, 6);
  84.                 String l = "(L)";
  85.                 Font lFont = new Font("Arial", Font.BOLD, 6);
  86.                 String lotn = "0350";
  87.                 Font lotFont = new Font("Arial", Font.BOLD, 14);
  88.                 Barcode barcodelot = BarcodeFactory.createCode39("L0350", false);
  89.                 barcodelot.setDrawingText(false);
  90.                 barcodelot.setBarHeight(42);
  91.                 barcodelot.setBarWidth(1);
  92.                 BufferedImage imagelot = BarcodeImageHandler.getImage(barcodelot);
  93.                 ///////////////
  94.                 String cus = "Customer No.";
  95.                 Font cusFont = new Font("Arial", Font.BOLD, 6);
  96.                 String cust_n = "AL1T 18812 AB";
  97.                 Font cus_nFont = new Font("Arial", Font.BOLD, 14);
  98.                  String country2 = "ASSEMBLED IN MEXICO";
  99.                 Font country2Font = new Font("Arial", Font.BOLD, 10);
  100.                  String julian="1216";
  101.                   Font julianFont = new Font("Arial", Font.BOLD, 5);
  102.                  String serial = "0001";
  103.                   Font serialFont = new Font("Arial", Font.BOLD, 5);
  104.                 ///////////////
  105.                 g2d.setFont(countryFont);
  106.                 FontMetrics countryfontMetrics = g2d.getFontMetrics();
  107.                 g2d.drawString(country, 51, 12);
  108.                 g2d.setFont(itemFont);
  109.                 FontMetrics itemfontMetrics = g2d.getFontMetrics();
  110.                 g2d.drawString(item, 6, 24);
  111.                 g2d.setFont(nFont);
  112.                 FontMetrics nfontMetrics = g2d.getFontMetrics();
  113.                 g2d.drawString(n, 15, 33);
  114.                 g2d.setFont(itemnFont);
  115.                 FontMetrics itemnfontMetrics = g2d.getFontMetrics();
  116.                 g2d.drawString(itemn, 82, 32);
  117.                 g2d.drawImage(image, 18, 37, null);
  118.                 ////////////////////
  119.                 g2d.setFont(qualityFont);
  120.                 FontMetrics qualityfontMetrics = g2d.getFontMetrics();
  121.                 g2d.drawString(quality, 6, 93);
  122.                 g2d.setFont(qFont);
  123.                 FontMetrics qfontMetrics = g2d.getFontMetrics();
  124.                 g2d.drawString(q, 15, 102);
  125.                 g2d.setFont(qtyFont);
  126.                 FontMetrics qtyfontMetrics = g2d.getFontMetrics();
  127.                 g2d.drawString(qtyn, 115, 96);
  128.                 g2d.drawImage(imageqty, 86, 97, null);                
  129.                 ////////////////////                
  130.                  g2d.setFont(loteFont);
  131.                 FontMetrics lotefontMetrics = g2d.getFontMetrics();
  132.                 g2d.drawString(lote, 6, 150);
  133.                 g2d.setFont(lFont);
  134.                 FontMetrics lfontMetrics = g2d.getFontMetrics();
  135.                 g2d.drawString(l, 12, 159);
  136.                 g2d.setFont(lotFont);
  137.                 FontMetrics lotfontMetrics = g2d.getFontMetrics();
  138.                 g2d.drawString(lotn, 109, 152);
  139.                 g2d.drawImage(imagelot, 83, 153, null);
  140.                 ////////////////////
  141.                 g2d.setFont(cusFont);
  142.                 FontMetrics cusfontMetrics = g2d.getFontMetrics();
  143.                 g2d.drawString(cus, 6, 204);
  144.                 g2d.setFont(cus_nFont);
  145.                 FontMetrics cust_nfontMetrics = g2d.getFontMetrics();
  146.                 g2d.drawString(cust_n, 80, 209);
  147.                 g2d.setFont(country2Font);
  148.                 FontMetrics country2fontMetrics = g2d.getFontMetrics();
  149.                 g2d.drawString(country2, 76, 225);
  150.  
  151.                 ////////////////////
  152.             } catch (OutputException ex) {
  153.                 Logger.getLogger(JavaWorldPrintExample3.class.getName()).log(Level.SEVERE, null, ex);
  154.             } catch (BarcodeException ex) {
  155.                 Logger.getLogger(JavaWorldPrintExample3.class.getName()).log(Level.SEVERE, null, ex);
  156.             }return PAGE_EXISTS;
  157.  
  158.    }
  159.   }  
  160. }

  #2 (permalink)  
Antiguo 12/04/2011, 10:02
Avatar de valdo_kof  
Fecha de Ingreso: noviembre-2009
Ubicación: San Juan del Rio, Qro
Mensajes: 192
Antigüedad: 14 años, 5 meses
Puntos: 16
Respuesta: impresion y diseño de etiquetas

gracias por interesarse pero ya lo solucione

Etiquetas: diseño, etiquetas, impresion
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 08:29.