Java UPC-A Generator Tutorial

Generate, create barcode UPC-A images in Java applications(Servlet, Class, Jasper Report)

Generate, Create, Print, Draw UPC-A barcode in Java projects

  • Easy to generate UPC-A barcodes in Java Class, J2EE applications
  • Simple to redistribute Java UPC-A barcode library. No registration key. No activation code.
  • Generating high quality UPC-A Bar Code images in GIF, JPEG, Png & EPS formats
  • Generate UPC A barcodes in Jasper Reports, iReport & Eclipse BIRT
  • Completely developed in Java
  • Creating UPC-A with addon symbols of two or five digits
  • Mature UPC A barcode generation Java library used by 2000+ clients


How to create, print UPC-A barcode in Java web, desktop application?

  1. Download Java UPC-A Barcode Generator library
  2. Install Java UPC-A barcode generation library into Java project
  3. Start to Create










Java Barcode UPC-A Generator Introduction

Top
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 UPC-A Introduction

UPC-A is also known as Universal Product Code version A, UPC-A Supplement 5/Five-digit Add-On, UPC-A Supplement 2/Two-digit Add-On, UPC-A+5, UPC-A+2, UPC Code, UPC Symbol, GTIN-12, GS1-12, UCC-12

Java UPC-A Generator - Valid Data Scope

Java UPC-A Generator encodes:

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




How to Generate UPC-A Barcodes in Java Class?

Top
Provided below is some Java demo code for generating UPC-A barcode images in Java class. You can simply copy to your barcoding project for a test. Here is some more advanced UPC-A settings and sample codings: Java UPC-A Generator Demo Source Code
// Create Java UPCA object 
UPCA barcode = new UPCA();

// Set UPCA data text to encode. It must be 11 digits, without the first number system
and the last checksum digit.
barcode.setData("12345678912");

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

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

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

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





Print and customize UPC-A barcode in Java web, desktop applications

Top
Using OnBarcode Java UPC-A Barcode Generator library, you can create and customize printed UPC-A barcode using the following barcode options in Java web, desktop applications
  • ShowQuietZoneIndicator: Display or hide UPC barcode quiet zone indicator. The default value is true.
  • UPCEANLeadDigitSpace: The space between the first digit and the start character bar. The default value is 0.
  • UPCEANTrailDigitSpace: The space between the stop character bar and the quiet zone indicator. The default value is 0.
  • UPCEANLeadTrailDigitSizeRatio: The first and last digit font size vs the rest digits font size. The default value is 1.0f

Here we will explain how to generate and customize the UPC-A barcode images below using the above UPC-A barcode options using Java source codes.





UPC add-on quiet zone indicator

You can display or hide the UPC-A with add-on barcode quiet zone indicator in UPC-A barcode label. By default, the Java barocde library will print the UPC quiet zone indicator mark on the right side of the UPC-A barcode.

The property ShowQuietZoneIndicator will allow you to hide the UPC-A with add-on quiet zone indicator.

barcode.ShowQuietZoneIndicator = false;



UPC-A the first and last digit space and font size

You can increase the space between the UPC-A first code and the start bar, and the space between the stop char and quiet zone indicator through barcode options UPCEANLeadDigitSpace and UPCEANTrailDigitSpace.

And you can also customize the UPC-A first and last digit font size through option UPCEANLeadTrailDigitSizeRatio. The option value is the first and last digit font size vs the rest digits font size.

barcode.UPCEANLeadDigitSpace = 10;
barcode.UPCEANTrailDigitSpace = 10;
barcode.UPCEANLeadTrailDigitSizeRatio = 0.6f;





How to Create UPC-A Image in Html or JSP Pages?

Top
  1. Under demo package, copy barcode folder and its contents to your tomcat
  2. Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=12345678912&TYPE=UPCA
  3. To create UPC-A bar code images in html or JSP pages, you can insert a image tag (img) into your page
  4. Example tag, <img src="http://YourDomain:Port/barcode/barcode?DATA=12345678912&TYPE=UPCA" />




How to Generate UPC-A Image in Java Servlet Class?

Top
import com.onbarcode.barcode.AbstractBarcode; 
import com.onbarcode.barcode.UPCA;
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 {
UPCA barcode = new UPCA();
barcode.setData("12345678912");

ServletOutputStream servletoutputstream = response.getOutputStream();

response.setContentType("image/jpeg");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

// Generate UPCA barcode & output to ServletOutputStream
barcode.drawBarcode(servletoutputstream);

} catch (Exception e) {
throw new ServletException(e);
}
}
}




How to Generate & Print Barcode UPC-A Image in Jasper Reports?

Top
This Java Barcode Generator supports generating UPC-A barcodes in Jasper Reports. Two methods are supported: through JRRenderable implementation or Java Generator buildin Servlet application. Here is the Complete Guide for Barcode Generation in Jasper Reports.




How to Generate & Print Barcode UPC-A Image in iReport?

Top
Besides Jasper Report, this Java Generator also supports creating & embedding UPC-A linear barcode images in iReport with two methods. Here is the detailed guide: Complete Guide for Barcode Generation in iReport




How to Generate & Print Barcode UPC-A Image in Eclipse BIRT?

Top

How to Set Generated Barcode UPC-A Image Width and Height?

Top
  1. You can set barcode image width and height through properties barcodeWidth and barcodeHeight values.
  2. Or else you can set X (bar module width) and Y (bar module height) values




Java UPC-A Generator - Property Settings

Top
Java UPC-A Generator in Java Class: com.onbarcode.barcode.UPCA

View the details here: complete UPC-A barcode property settings in Java class













Common Asked Questions

What is a GTIN-12 UPC-A barcode?

GTIN-12 is a 12 digits Global Trade Item Number. It is usually encoded in UPC-A barcode. The 12 digits Global Trade Item Number includes 11 digits of data message, and one digit of check sum digit. Using Java Barcode Library, you can input 12-digit GS1 numeric data or 13-digits data with checksum digit in class com.onbarcode.barcode.UPCA in Java source code.

What is the minimum & maximum size for a UPC-A barcode?

  • The Minimum X-dimension for the UPC-A barcode is 0.0104 inches.
  • The Maximum X-dimension for the UPC-A barcode is 0.0260 inches
You can apply the UPC-A barcode X-dimension through methodsetX() in Java barcode class UPCA using Java Barcode Generator library.

What is the difference between EAN-13 and UPC-A?

UPC-A Format barcodes have traditionally been used in the North America (USA and Canada), whereas EAN-13 format barcodes have been used throughout the rest of the world. Java Barcode Generator SDK supports both UPC-A and EAN-13 with add-on symbol barcode generation in Java class, desktop application, JSP, Servlet web application.

What is the difference between UPC-A and UPC-E?

Both of UPC-A and UPC-E are UPC barcode. UPC-A is a 12-digit barcode, and UPC-E is a compressed UPC-A with 6 digits code. The UPC-E will be used in limited space for a barcode. You can create both UPC-A and UPC-E images in Java projects using Java barcode library.




































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.