KA.Barcode for Java
Java Barcode EAN-8 Generation Guide
Create & Print EAN-8 using Java Barcode Generator

Java EAN-8 - Introduction


It is also known as European Article Number 8, EAN-8 Supplement 5/Five-digit Add-On, EAN-8 Supplement 2/Two-digit Add-On, EAN-8+5, EAN-8+2, EAN8, EAN8+5, EAN13+2, UPC-8, GTIN-8, GS1-8, EAN/UCC-8

c# generate barcode, how to print barcode labels in c# windows application, print barcode in c# windows application, barcode reader c# github, free barcode generator in asp.net c#, barcode scanner code in c# windows application

An EAN-8 is a barcode and is derived from the longer European Article Number (EAN-13) code. It was introduced mainly to use on small packages where an EAN-13 barcode would be impractical; for example on cigarettes, pencils even though not used very common and chewing gum packets.

Java Barcode EAN-8 Generator - How to generate EAN-8 barcodes in Java class?


    //Create BarCode object in Java
    BarCode barcode = new BarCode(); 
    
    //Set barcode symbology type to EAN8
    //IBarCode.EAN8 for EAN-8 without supplement code
    //IBarCode.EAN8_2 for EAN-8 with 2 digits supplement code
    //IBarCode.EAN8_5 for EAN-8 with 5 digits supplement code
    barcode.setType(IBarCode.EAN8_2); 
    
    //Set EAN-8 encoding code value. It should be 7 digits.
    barcode.setData("0123456"); 
    
    //EAN-8 supplement code. It should be 2 or 5 digits.
    barcode.setSupData("01");
    
    
    //Set EAN-8 image size
    barcode.setUOM(IBarCode.UOM_PIXEL);        // EAN-8 unit of measure
    barcode.setResolution(72);                 // EAN-8 image resolution in dpi
    barcode.setX(3);                           // EAN-8 bar module width (X dimention)
    barcode.setY(50);                          // EAN-8 bar module height (Y dimention)
    barcode.setLeftMargin(0);		       // EAN-8 image left margin size
    barcode.setRightMargin(0);		       // EAN-8 image right margin size
    barcode.setTopMargin(0);		       // EAN-8 image top margin size
    barcode.setBottomMargin(0);		       // EAN-8 image bottom margin size
    barcode.setRotate(IBarCode.ROTATE_0);      // EAN-8 rotation
    
    //Set EAN8 human readable text style
    barcode.setDisplayText(true);              // Display human readable text
    barcode.setTextFont(new Font("Arial", Font.PLAIN, 11));
    
    
    //Generate EAN-8 barcodes in image GIF format
    barcode.draw("barcode-ean8-java.gif");

    //Create EAN-8 barcodes in OutputStream object
    barcode.draw("Java java.io.OutputStream Object");
    
    //Draw & Print EAN-8 barcodes to Graphics2D object within specified region
    barcode.draw("java.awt.Graphics2D", "java.awt.geom.Rectangle2D");
    
    //Generate EAN-8 barcodes & write to byte[] 
    byte[] barcodeInBytes = barcode.drawOutputAsBytes();
    
    //Generate EAN-8 barcodes & encode to System.Drawing.Bitmap object 
    BufferedImage barcodeImage = barcode.draw();


Java Barcode EAN-8 Generator - How to create EAN-8 barcodes in Java web applications?

  • How to generate barcode image in html or jsp pages?

    1. Download trial package, unzip it, copy barcode folder and its contents to your Java Servlet container like Tomcat, or Jboss.

    2. Start Tomcat, navigate to http://url:port/barcode/barcode?data=0123456789&type=4

    3. To generate barcodes in html page or jsp page, insert the following html code.
      <img src="http://url:port/barcode/barcode?data=0123456789&type=4" />

  • How to generate barcode image in Java Servlet?

      public void doPost(HttpServletRequest request, HttpServletResponse response) throws
       ServletException 
        { 
            try { 
                BarCode barcode = new BarCode();
                barcode.setType(BarCode.CODE39); 
                barcode.setData("0123456789"); 
                 
                ServletOutputStream sout = response.getOutputStream(); 
     
                response.setContentType("image/jpeg"); 
                response.setHeader("Pragma", "no-cache"); 
                response.setHeader("Cache-Control", "no-cache"); 
                response.setDateHeader("Expires", 0); 
     
                barcode.drawBarcode(sout); 
     
            } catch (Exception e) { 
                throw new ServletException(e); 
            } 
        } 
    


Java Barcode EAN-8 Generator - How to draw & print EAN-8 barcodes in Java Reporting projects



Java EAN-8 - Property Settings

Class Attribute HTTP Parameter Default Value Comments
Basic
type type -1 Barcode symbology type
data data "" Barcode value to encode
supData sup-data "" Barcode supplementary value to encode. Apply for EAN-8, EAN-13, UPC-A, UPC-E, ISBN, ISSN
applyChecksum apply-checksum true Checksum for barcode data
 
Barcode Size
uom uom IBarCode.UOM_PIXEL Unit of meature for all size related settings. UOM_PIXEL (0); UOM_CM (1); UOM_INCH (2). Default is UOM_PIXEL
X x 2 Width of barcode module (narrow bar), default is 2 pixel
Y y 75 Barcode module height, default is 75 pixel
leftMargin left-margin 0 Barcode image left margin
rightMargin right-margin 0 Barcode image right margin
topMargin top-margin 0 Barcode image top margin
bottomMargin bottom-margin 0 Barcode image bottom margin
resolution resolution 72 Barcode image resolution in dpi
rotate rotate IBarCode.ROTATE_0 Barcode rotate angle, valid values: IBarCode.ROTATE_0 (0), IBarCode.ROTATE_90 (1), IBarCode.ROTATE_180 (2), IBarCode.ROTATE_270 (3)
 
Text Style
displayText display-text true If true, display barcode value text, otherwise do not display.
textFont text-font "Arial", Font.PLAIN, 11 Barcode text font style
 
Code 39
displayStartStopChar display-start-stop-char true If true, display the start and stop char (*) in the begining and end of barcode value.
wideNarrowRatio wide-narrow-ratio 2.0f wide vs narrow bar width ratio. for Code39, Code 2 of 5, Interleaved 2 of 5, Identcode, Leitcode, ITF14.
 
ITF14
bearerBar bearer-bar IBarCode.BEARERBAR_NONE Bearer bars for ITF14. BEARERBAR_NONE (0), BEARERBAR_FRAME (1), BEARERBAR_TOPBOTTOM (2)
 
Code 128 & UCC/EAN/GS1 128
processTilde process-tilde false Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255.
eci eci 3
fnc1Mode fnc1-mode 0 (none)
applicationIndicator ai 0