Java Barcode EAN 13 Generator

Index
 

Java Barcode Introduction

Java Barcode is a Java barcode generator which generates high quality 1D (linear) and 2D (matrix) barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects.

 

Barcode EAN-13 Introduction

EAN-13 barcode (originally European Article Number) is a barcoding standard which is a superset of the original 12-digit Universal Product Code (UPC) system developed in the United States. The EAN-13 barcode is defined by the standards organisation GS1. The numbers encoded in EAN-13 bar codes are product identification numbers which are called Japanese Article Number (JAN) in Japan. All the numbers encoded in UPC and EAN barcodes are known as Global Trade Item Numbers (GTIN), and they can be encoded in other GS1 barcodes.

 

Java EAN 13 Generator - Valid Data Scope

Java EAN 13 Generator supports:



 

Java EAN 13 Generator - Property Settings


Java EAN 13 Generator in Java Class: com.onbarcode.barcode.EAN13

Category Class Properties Servlet Properties Default Comments
Basic data DATA "" value to encode. valid data is 12 digits.
addCheckSum ADD-CHECK-SUM true addCheckSum property is not applied here. Java Barcode will always add a check character in the last digit (modulo 10).
 
UPC/EAN Related supData SUP-DATA "" Set the supData property with the supplementary data to encode.
supHeight SUP-HEIGHT 0.8 This is a multiplicator of the height of the code; The default is 0.8 (80%).
supSpace SUP-SPACE 15 The separation between the barcode and the supplement
 
Size Related uom UOM 0 Unit of meature for all size related setting in the library.
0: pixel; 1: inch; 2: cm.
X X 1 width of barcode module (narrow bar), default is 1 pixel
Y Y 30 barcode module height, default is 30 pixel
barcodeWidth BARCODE-WIDTH 0 generted barcode image width
barcodeHeight BARCODE-HEIGHT 0 generted barcode image height
leftMargin LEFT-MARGIN 0 image left margin
rightMargin RIGHT-MARGIN 0 image right margin
topMargin TOP-MARGIN 0 image top margin
bottomMargin BOTTOM-MARGIN 0 image bottom margin
resolution RESOLUTION 72 in DPI
rotate ROTATE IBarcode.ROTATE_0 (0) valid values:
IBarcode.ROTATE_0 (0),
IBarcode.ROTATE_90 (1),
IBarcode.ROTATE_180 (2),
IBarcode.ROTATE_270 (3)
 
Text
&
Color
showText SHOW-TEXT true If true, display barcode data text, otherwise do not display.
showCheckSumChar SHOW-CHECKSUM-CHAR true If true, display the check sum character in the end of data, if there is a check sum.
textFont TEXT-FONT Arial, Plain, 11 Barcode text font style
textMargin TEXT-MARGIN 6 Space between barcode and barcode data text, default is 6 pixel
 



Java Barcode EAN 13 Generation FAQ?

  1. How to generate barcode EAN 13 in Java class?
    8     EAN13 barcode = new EAN13(); 
    9           barcode.setData("012345678912"); 
    10          barcode.drawBarcode("C://barcode-ean13.gif"); 
    

    Barcode EAN 13

  2. How to create barcode EAN 13 image in html or jsp pages?

    • Under demo package, copy barcode folder and its contents to your tomcat.

    • Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=012345678912&TYPE=EAN13

    • To create bar code images in html or jsp pages, you can insert a image tag (img) into your page.
      For example, <img src="http://YourDomain:Port/barcode/barcode?DATA=012345678912&TYPE=EAN13" />



  3. How to create barcode EAN 13 image in Java Servlet?
    
    1    package com.onbarcode.barcode.test; 
    2     
    3    import com.onbarcode.barcode.AbstractBarcode; 
    4    import com.onbarcode.barcode.EAN13; 
    5     
    6    import javax.servlet.http.HttpServlet; 
    7    import javax.servlet.http.HttpServletRequest; 
    8    import javax.servlet.http.HttpServletResponse; 
    9    import javax.servlet.ServletException; 
    10   import javax.servlet.ServletOutputStream; 
    11    
    12   public class TestServlet extends HttpServlet 
    13   { 
    14       public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException 
    15       { 
    16           try { 
    17               EAN13 barcode = new EAN13(); 
    18               barcode.setData("012345678912"); 
    19                
    20               ServletOutputStream servletoutputstream = response.getOutputStream(); 
    21    
    22               response.setContentType("image/jpeg"); 
    23               response.setHeader("Pragma", "no-cache"); 
    24               response.setHeader("Cache-Control", "no-cache"); 
    25               response.setDateHeader("Expires", 0); 
    26    
    27               barcode.drawBarcode(servletoutputstream); 
    28    
    29           } catch (Exception e) { 
    30               throw new ServletException(e); 
    31           } 
    32       } 
    33   } 
    34   


  4. How to draw barcode EAN 13 into image file?
    8     EAN13 barcode = new EAN13(); 
    9            barcode.setData("012345678912"); 
    10          barcode.drawBarcode("C://barcode-ean13.gif"); 
    


  5. How to draw & write barcode EAN 13 to Java OutputStream or Graphics2D objects?

    Please call the following methods to draw & write barcode EAN 13 to Java OutputStream or Graphics2D objects

    1. public boolean drawBarcode(OutputStream outputStream) throws Exception
    2. public void drawBarcode(Graphics2D g, Rectangle2D rectangle) throws Exception


  6. How to generate barcode EAN 13 image in Jasper Reports?

    Complete Guide for Barcode Generation in Jasper Reports

  7. How to generate barcode EAN 13 image in iReport?

    Complete Guide for Barcode Generation in iReport

  8. How to generate barcode EAN 13 image in Eclipse BIRT?

    Complete Guide for Barcode Generation in Eclipse BIRT

  9. How to set generated barcode EAN 13 image width and height?

    1) You can set barcode image width and height through properties barcodeWidth and barcodeHeight values.

    or

    2) You can set X (bar module width) and Y (bar module height) values




More Information



Java Barcode Generator Tutorial

All Java Barcode Supported Types

1D / Linear Barcodes

Codabar   |    Code 11   |    Code 39   |    Extended Code 39
Code 93   |    Code 128   |    UCC/EAN128 (GS1-128)   |    Interleaved 2 of 5
Code 2 of 5 (Industrial 2 of 5)   |    ITF14   |    UPC-A   |    UPC-E
EAN-8   |    EAN-13   |    ISBN   |    ISSN
MSI Plessey   |    POSTNET   |    PLANET   |    Intelligent Mail Barcode OneCode
Identcode   |    Leitcode   |    RM4SCC


GS1 DataBar

GS1 DataBar (coming soon)


2D Barcodes

Data Matrix   |    PDF 417   |    Macro PDF417   |    QR Code