Java EAN-8 Generator generate, create barcode
EAN-8 images in Java application

Download Java Barcode Generator Free Evaluation
Purchase Java Barcode Generator SDK License

Generate, Create, Print, Draw EAN-8 barcode in Java projects


  • Easy to generate EAN-8 barcodes in Java Class, J2EE applications
  • Simple to redistribute Java EAN-8 barcode library. No registration key. No activation code.
  • Generating high quality EAN-8 Bar Code images in GIF, JPEG, & EPS formats
  • Generate EAN 8 barcodes in Jasper Reports, iReport & Eclipse BIRT
  • Completely developed with Java source code
  • Mature EAN 8 barcode generation Java library used by 2000+ clients


Index
 

Java Barcode EAN-8 Generator 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-8 Introduction

EAN-8 is a barcode and is derived from the longer European Article Number (EAN-13) code. It was introduced for use on small packages where an EAN-13 barcode would be too large.

 

Java EAN-8 Generator - Valid Data Scope

Java EAN 8 Generator encodes:

  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9



 

Java Barcode EAN-8 Generation FAQ

  1. How to generate barcode EAN-8 in Java class? (Complete Java EAN-8 Generator Demo Source Code)

    // Create Java EAN8 object 
    EAN8 barcode = new EAN8(); 
    
    // Set EAN8 data text to encode. It must be 7 digits, without last checksum digit.
    barcode.setData("1234567"); 
    
    // Generate EAN8 barcode & print into Graphics2D object
    barcode.drawBarcode("Java Graphics2D object"); 
    
    // Generate EAN8 barcode & encode into GIF format
    barcode.drawBarcode("C://barcode-ean8.gif"); 
    
    // Generate EAN8 barcode & encode into JPEG format
    barcode.drawBarcode("C://barcode-ean8.jpg"); 
    
    


  2. How to generate & encode EAN-8 barcodes to EPS?

    // Create Java EAN8 object 
    EAN8 barcode = new EAN8(); 
    
    // Set EAN8 data text to encode. It must be 7 digits, without last checksum digit.
    barcode.setData("1234567"); 
    
    // Generate EAN8 barcode & encode into EPS
    barcode.drawBarcode2EPS("C://barcode-ean8.eps"); 


  3. How to create & encode EAN-8 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=1234567&TYPE=EAN8

    • 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=1234567&TYPE=EAN8"/>



  4. How to create & print barcode EAN-8 image in Java Servlet class?

    import com.onbarcode.barcode.AbstractBarcode; 
    import com.onbarcode.barcode.EAN8; 
    import javax.servlet.http.HttpServlet; 
    import javax.servlet.http.HttpServletRequest; 
    import javax.servlet.http.HttpServletResponse; 
    import javax.servlet.ServletException; 
    import javax.servlet.ServletOutputStream; 
       
    public class BarcodeServlet extends HttpServlet 
    { 
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException 
        { 
            try { 
                EAN8 barcode = new EAN8(); 
                barcode.setData("1234567"); 
                     
                ServletOutputStream servletoutputstream = response.getOutputStream(); 
                
                response.setContentType("image/jpeg"); 
                response.setHeader("Pragma", "no-cache"); 
                response.setHeader("Cache-Control", "no-cache"); 
                response.setDateHeader("Expires", 0); 
               
                // Generate EAN8 barcode & output to ServletOutputStream
                barcode.drawBarcode(servletoutputstream); 
          
            } catch (Exception e) { 
                throw new ServletException(e); 
            } 
        } 
    } 


  5. How to generate & print barcode EAN-8 image in Jasper Reports?



    Complete Guide for Barcode Generation in Jasper Reports

  6. How to generate & print barcode EAN-8 image in iReport?



    Complete Guide for Barcode Generation in iReport

  7. How to generate & print barcode EAN-8 image in Eclipse BIRT?



    You can stream barcodes into your BIRT reports using Java Barcode Generator.

    However we recommend you use our BIRT Barcode Generator Plugin to generate and print EAN 8 barcodes in your BIRT reports.

  8. How to set generated barcode EAN-8 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

 

Java EAN 8 Generator - Property Settings


Java EAN 8 Generator in Java Class: com.onbarcode.barcode.EAN8

Category Properties Value Comments
Basic Property: data
URL: DATA
Type: String
Default: ""
Barcode value to encode

EAN 8 Valid Data Char Set:
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (Digits)

EAN 8 Valid data length:
  • 7 digits only, excluding the last checksum digit.

Property: addCheckSum
iReport & URL: ADD-CHECK-SUM
Type: boolean
Default: false
addCheckSum property is not applied here. Java Barcode will always add a check character in the last digit (modulo 10).
 
EAN-8 Related Property: supData
URL: SUP-DATA
Type: String
Default: ""
Set the supplement data to encode. Valid values are 2 or 5 digits
Property: supHeight
iReport & URL: SUP-HEIGHT
Type: float
Default: 0.8f
This is a multiplicator of the height of the bar module; The default is 0.8 (80% of Y - bar module height).
Property: supSpace
iReport & URL: SUP-SPACE
Type: float
Default: 15
The separation between the barcode and the supplement. Default is 15 pixel.
 
Barcode
Size
Related
Property: autoResize
iReport & URL: AUTO-RESIZE
Type: boolean
Default: false
Auto resize the generated barcode image
Property: barAlignment
iReport & URL: BAR-ALIGNMENT
Type: int
Default: 1 (center)
Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
Property: uom
iReport & URL: UOM
Type: int
Default: 0 (pixel)
Unit of meature for all size related settings in the library.
Valid values: 0: pixel; 1: inch; 2: cm.
Property: X
iReport & URL: X
Type: float
Default: 1
Width of barcode bar module (narrow bar), default is 1 pixel
Property: Y
iReport & URL: Y
Type: float
Default: 30
Height of barcode bar module, default is 30 pixel
Property: barcodeWidth
iReport & URL: BARCODE-WIDTH
Type: float
Default: 0
Generated EAN 8 barcode image width.

If barcodeWidth value is smaller than the barcode required minimum width size, Java barcode library will automatically reset barcodeWidth value to barcode minimum width.
Property: barcodeHeight
iReport & URL: BARCODE-HEIGHT
Type: float
Default: 0
Generated EAN 8 barcode image height.

If barcodeHeight value is smaller than the barcode required minimum height size, Java barcode library will automatically reset barcodeHeight value to barcode minimum height.
Property: leftMargin
iReport & URL: LEFT-MARGIN
Type: float
Default: 0
EAN-8 image left margin size.
Property: rightMargin
iReport & URL: RIGHT-MARGIN
Type: float
Default: 0
EAN-8 image right margin size.
Property: topMargin
iReport & URL: TOP-MARGIN
Type: float
Default: 0
EAN-8 image top margin size.
Property: bottomMargin
iReport & URL: BOTTOM-MARGIN
Type: float
Default: 0
EAN-8 image bottom margin size.
Property: resolution
iReport & URL: RESOLUTION
Type: int
Default: 72
EAN-8 barcode image resolution in DPI (Dots per inch).
Property: rotate
iReport & URL: ROTATE
Type: int
Default: 0 (IBarcode.ROTATE_0)
Rotate EAN 8 images in 0, 90, 180, 270 angles.

Valid values:
  • 0 (IBarcode.ROTATE_0)
  • 1 (IBarcode.ROTATE_90)
  • 2 (IBarcode.ROTATE_180)
  • 3 (IBarcode.ROTATE_270)
 
Barcode
Colors
Property: backColor
iReport & URL: BACK-COLOR
Type: Color
Default: white
Barcode image background color
Property: foreColor
iReport & URL: FORE-COLOR
Type: Color
Default: black
Barcode image foreground color
 
Font
Style
Property: showText
iReport & URL: SHOW-TEXT
Type: boolean
Default: true
If true, printing EAN 8 encoding data below the barcode, otherwise do not print.
Property: textFont
iReport & URL: TEXT-FONT
Type: Font
Default:
new Font("Arial", Font.PLAIN, 11)
EAN 8 text (printed below barcode) font style.

In Java Servlet web streaming, using the url paramter in the following format:
&TEXT-FONT=Arial|plain|11
Property: textMargin
iReport & URL: TEXT-MARGIN
Type: float
Default: 6
Space between barcode and printed barcode data, default is 6 pixel
Property: textColor
iReport & URL: TEXT-COLOR
Type: Color
Default: black
Barcode text (printed below barcode) color
 
Methods
// 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









OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.