.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Home > Java Barcode > Java EAN-8 Generator

Java EAN-8 Generator

Java EA-8 Generation package to generate EAN-8 linear barcodes in Java applications.

  • Mature Java EAN-8 package consists of class library contains all necessary class files for java EAN-8 barcode generation.

  • Easily create high-quality linear barcodes images of AWT, JPEG, and GIF formats in Java, Java Class, J2EE applications.

  • Royalty free with a permanent license by Avapose.

  • Java EAN-8 can be easily generated on any operating system with a JVM.

  • Generate EAN-8barcodes in Jasper Reports, iReport & Eclipse BIRT

  • Java EAN-8 generator is compatible with JDK 1.4.0 or greater.

Java EAN-8 Generator - Overview

Java EAN-8 generator is a mature and reliable Java barcode generation component for creating EAN-8barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects. High-quality EAN-8 barcode images can be drawn and printed into GIF, BMP, PNG, JPEG/JPG & TIFF formats with Java EAN-8 barcode generator. Rich barcode options are provided to customize EAN-8 barcode properties in accordance with your needs.

EAN-8 information:

EAN-8: a short version of EAN-13, is a numeric-only UPC-based barcode symbology and consists of 8 characters. It is widely used for smaller packages.

Available encoding data:

numeric digits: 0-9

7 digits length only

The structure of a EAN-8:

1. Left-hand guard bars, or start sentinel, encoded as 101.
2. Two number system characters, encoded as left-hand odd-parity characters.
3. First two message characters, encoded as left-hand odd-parity characters.
4. Center guard bars, encoded as 01010.
5. Last three message characters, encoded as right-hand characters.
6. Check digit, encoded as right-hand character.
7. Right-hand guar bars, or end sentinel, encoded as 101.

Note that "1" represents a bar while "0" represents a space.


Java EAN-8 Generator Implementation to Generate EAN-8

1. Generate EAN-8 in Java class by changing of barcode properties.

// Create Java EAN-8 object
EAN8 barcode = new EAN8( );

// Set barcode data text to encode
barcode.setData("1234567");

// Generate barcode & print into Graphics2D object
//barcode.drawBarcode("Java Graphics2D object");

// Generate barcode & encode into GIF format
barcode.drawBarcode("C://barcode-ean8.gif");

// Generate barcode & encode into JPEG format
barcode.drawBarcode("C://barcode-ean8.jpg");


2. Generate & encode EAN-8 to EPS by changing the values concerned.

// Create Java barcode object
Codbar barcode = new EAN8();

// Set barcode data text to encode
barcode.setData("1234567");

// Generate barcode & encode into EPS format
barcode.drawBarcode2EPS("C://barcode-ean8.eps");


3. Generate & encode EAN-8 in html or jsp pages.

1. Copy barcode folder and its contents from demo package to Apache Tomcat.

2. Start Apache Tomcat, go to http://YourDomain:Port/barcode/barcode?DATA=1234567&TYPE=EAN8

3. Insert an image tag (img) into your page. For example,

<imgsrc="http://YourDomain:Port/barcode/barcode?DATA=1234567&TYPE=EAN8" />

4. Two ways to set the width and height of generated barcode EAN-8 image

1. Set the values of the barcodeWidth and barcodeHeight properties.
or
2. Set X (bar module width) and Y (bar module height) values

EAN-8 Property Settings in Java Barcode Generator

EAN-8 Basic Settings

Properties Value
Comments
Property URL Options Default
data DATA (Data to encode in the Codabar) ""

EAN-8 value to encode

EAN-8 Character Set:
  • Digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9;

addCheckSum ADD-CHECK-SUM (Data to encode in the Codabar) false

addCheckSum property is not applied here. Code 2of 5does not require any checksum.

EAN-8 Related Settings

Properties Value
Comments
Property URL Options Default
supData
NSUP-DATA
String
"" Set the supplement data to encode. Valid values are 2 or 5 digits
supHeight
SUP-HEIGHT
float
0.8of A multiplicator of the height of the bar module; The default is 0.8 (80% of Y - bar module height).
supSpace
SUP-SPACE
float
15 The separation between the barcode and the supplement. Default is 15 pixel.

EAN-8 Text Settings

Properties Value
Comments
Property URL Options Default
showText

SHOW-TEXT
true or false
true


Show text underneath the barcode

textColor

TEXT-COLOR
Color
black

Color of the shown text

textFont
TEXT-FONT
Font
new Font("Arial",Font.PLAIN,11)

The font, font style and font size of the text

textMargin
TEXT-MARGIN
float
6

The space between the text and the barcode symbol

EAN-8 Size Settings

Properties Value
Comments
Property URL Options Default
rotate

ROTATE
Degree0, 90, 180, 270
0 (Barcode.ROTATE)


Rotate the Angle of the Codabar images with:

0 (IBarcode.ROTATE_0)
1 (IBarcode.ROTATE_90)
2 (IBarcode.ROTATE_180)
3 (IBarcode.ROTATE_270)

autoResize

AUTO-RESIZE
true or false
false

Auto resize the generated barcode image

barcodeHeight
BARCODE-HEIGHT
float
0

Barcode image Height

barcodeWidth
BARCODE-WIDTH
float
0

Barcode image Width

bottomMargin
BOTTOM-MARGIN
float
0

Barcode image bottom margin size
leftMargin LEFT-MARGINE float 0


Barcode image left margin size

rightMargin RIGHT-MARGIN float 0

Barcode image right margin size.

topMargin TOP-MARGIN float 0


Barcode image Top margin size
barAlignment BARALIGMENT int 1(center)


Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
uom
UOM
Pixel, Cm, or Inch
0(Pixel)

Unit of Measure for all numeric properties.Valid values: 0: pixel; 1: inch; 2: cm.
X X float 1

Width of barcode bar module (narrow bar), default is 1 pixel

Y Y float 30

Height of barcode bar module, default is 30 pixel

EAN-8 Color Settings

Properties Value
Comments
Property URL Options Default
backColor
BACK
-COLOR
Color
white

Barcode image background color

foreColor
FORE
-COLOR
color
black
Barcode image foreground color

EAN-8 Image Settings

Properties Value
Comments
Property URL Options Default
resolution
RESOLUTION
int
72

Resolution of Codabar Image, Dots Per Inch

Method

// generate barcode and output to OutputStream object
public boolean drawBarcode(OutputStream outputStream) throws Exception

// generate barcode into a new BufferedImage object
public BufferedImage drawBarcode() throws Exception

/*
Use this method to generate barcode, and save into gif or jpeg files
1. to save into gif file, filename ends with ".gif", like "c:\\barcode.gif"
2. to save into jpeg file, filename ends with ".jpg", like "c:\\barcode.jpg"
*/

public byte[] drawBarcodeToBytes() throws Exception

public boolean drawBarcode(String imageFile) throws Exception

// Generate barcode and save into EPS file, the filename must ends with ".eps"
public void drawBarcode2EPS(String filename) throws Exception

// Generate barcode on Graphics2D object within certain area
public void drawBarcode(Graphics2D g, Rectangle2D rectangle) throws Exception