Vous êtes sur la page 1sur 5

Java UPC-A Barcodes Generator for Java, J2EE, JasperReports

HOME PURCHASE SITEMAP COMPANY

Barcode for Java Barcode for .NET Barcode Reader for .NET Barcode Fonts Barcode Generator Purchase

Home > Java Barcode Generator > Java Barcode Generation Guide > Java UPC-A Barcodes Generator

Java UPC-A Barcodes Generator Guide


UPC-A Bar Code Generation Guide in Java class, J2EE, Jasper Reports, iReport & Eclipse BIRT

Easily generate UPC-A barcodes in Java applications


Generate high quality UPC-A images in JPEG, GIF & PNG formats
100% build in Java, compatible with JDK 1.4 and later version
Generate UPC-A barcodes on any platforms with a Java virtual machine
Generate UPC-A in Jasper Reports & iReport
Generate UPC-A in Eclipse BIRT
Mature Java Barcode Generator library since 2003
Royalty-free and perpetual developer license

Quick Navigate
Java Barcode Generator

1. Java UPC-A Introduction Barcode for Java


2. UPC-A Encoding Data Scope Barcode Generation
3. How to Generate UPC-A Image in Java Class? Guide

4. How to Generate UPC-A Image in Web Applications? Download

5. How to Generate UPC-A Image in Jasper Reports, iReport, Eclipse BIRT? License & Prices

6. Java UPC-A Property Settings

7. How to Set Generated UPC-A Barcode Image Size?

1. UPC-A Barcode 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

UPC-A is used for marking products which are sold at retail in the USA. The barcode identifies the manufacturer and specific product so point-of- sale cash
register systems can automatically look up the price.
The UPC-A Code and the assignment of manufacturer ID numbers is controlled in the U.S.A. by the Uniform Code Council (UCC).

Sample of a UPC-A Barcode

http://www.barcodelib.com/java_barcode/barcode_symbologies/upca.html[2/2/2011 11:41:08 PM]


Java UPC-A Barcodes Generator for Java, J2EE, JasperReports

The value to encode by UPC-A has the following structure:


1 digit for Number System (0: regular UPC codes, 1: reserved, 2: random weight items marked at the store, 3: National Drug Code and National Health
Related Items code, 4: no format restrictions, for in-store use on non-food items, 5: for use on coupons, 6: reserved, 7: regular UPC codes, 8: reserved, 9:
reserved)
5 digits for Manufacturer (Company) Code or prefix. This number is assigned by the Uniform Code Council (UCC)
5 digits for Product Code which is assigned by the manufacturer
1 digit for checksum

Add-On or Supplement code

The Add-On Symbols were designed to encode information supplementary to that in the main bar code symbol on periodicals and paperback books. The Add-On
can be composed of 2 or 5 digits only.

Sample of an UPC-A Two-Digit Add-On Barcode

Sample of an UPC-A Five-Digit Add-On Barcode

2. UPC-A Encoding Data Scope


UPCA Barcode for Java supports.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9

3. How to Generate UPC-A Barcode in Java Class?

The following Java code illustrates how to create a UPC-A barcode, and output to various formats

1 Linear linear = new Linear();


2 linear.setType(Linear.UPCA);
3 linear.setData("01234567890");
4 linear.renderBarcode("c:/barcode.gif");

5 BufferedImage bufferedImage = linear.renderBarcode();

6 byte[] barcodeBytes = linear.renderBarcodeToBytes();

7 Graphics2D g = ...
8 Rectangle2D rectangle = ...
9 linear.renderBarcode(g, rectangle);

10 OutputStream outputStream = ...


11 linear.renderBarcode(outputStream);

Create a Linear barcode object (line 1)


Set Linear object barcode type to UPC-A (line 2)
Set UPC-A barcode data to encode (line 3)

http://www.barcodelib.com/java_barcode/barcode_symbologies/upca.html[2/2/2011 11:41:08 PM]


Java UPC-A Barcodes Generator for Java, J2EE, JasperReports

Encode generated UPC-A barcode into gif image file (line 4)


Generate UPC-A and output to BufferedImage object (line 5)
Generate UPC-A in bitmap and output to byte[] (line 6)
Generate UPC-A and draw to defined area (Rectangle2D) on Graphics2D (line 7-9)
Generate UPC-A and output to OutputStream (line 10-11)

4. How to Generate UPC-A Barcode Image in Java Web Applications?

There are two methods to create UPC-A barcode images in your Java web applications.

1. The simplest way is to stream barcode image using our buildin barcode servlet application.

Download the Barcode for Java Trial Package, and unzip it.

Under java_barcode_trial package, copy barcode folder to your java servlet container like tomcat.

Restart tomcat. Now you have installed successfully.

To test your installation, open your web browser and navigate to


http://YourDomain:Port/barcode/linear?Data=01234567890&Type=UPCA

To create barcode image in your JSP or html page, you need pass the url to IMG tag src value. For example,
<img src="http://YourDomain:Port/barcode/linear?Data=01234567890&Type=UPCA" />

Using this method, it will not generate any barcode images in your server side.

2. The second method is to generate barcode images in your server side

Create a barcode image in server side

1 Linear linear = new Linear();


2 linear.setData("01234567890");
3 linear.setType(Linear.UPCA);
4 linear.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/barcode-images/barcode.gif");

In your JSP or HTML page, you need use IMG tag to display generated image, like
<img src="http://YourDomain:Port/YourWebApp/barcode-images/barcode.gif" />

5. How to Generate Barcode UPC-A Image in Jasper Reports, iReport, Eclipse BIRT?

How to generate UPC-A barcodes in Jasper Reports using Barcode for Java library?

How to generate UPC-A barcodes in iReport using Barcode for Java library?

How to generate UPC-A barcodes in Eclipse BIRT using Barcode for Java library?

http://www.barcodelib.com/java_barcode/barcode_symbologies/upca.html[2/2/2011 11:41:08 PM]


Java UPC-A Barcodes Generator for Java, J2EE, JasperReports

6. Java UPC-A Barcode Property Settings

1. Set the type property to Linear.UPCA, or Linear.UPCA_2, or Linear.UPCA_5


Servlet URL Parameter: "Type". Value: 40 (UPCA), 41 (UPCA +2), 42 (UPCA +5). Sample: &Type=40
2. Set the data property with the value to encode.
Type is String.
Valid Data Scope:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Valid Data Format: 11 digits, and DO NOT include last digit checksum character.
Sample: "12345678901"
Servlet URL Parameter: Data.
3. Set the sData property with the supplement value to encode. Type is String.
User should only provide 2 digits for UPCA_2, and provide only 5 digits for UPCA_5.
Servlet URL Parameter: SData.
4. addCheckSum property is not applied here. Barcode Library will always add a check character in the last digit (modulo 10).
5. Barcode image size settings:
Set property uom (Unit of Measure) for properties X, Y, leftMargin, rightMargin, topMargin and bottomMargin.
Default is Linear.UOM_PIXEL (0). Valid values are Linear.UOM_PIXEL (0), Linear.UOM_CM (1), Linear.UOM_Inch (2).
Servlet URL Parameter: "UOM". Value: 0 (pixel), 1 (cm), 2 (inch). Sample: &UOM=0
Set the X (for barcode module width) and Y (for barcode module height) properties.
Both types are float. Default X is 3. Y is 75.
Servlet URL Parameter: "X", "Y". Sample: &X=3&Y=75
Set the leftMargin, rightMargin, topMargin and bottomMargin properties, and types are all float.
Default values are 0 for all 4 margin settings.
Servlet URL Parameter: "LeftMargin", "RightMargin", "TopMargin", "BottomMargin". Sample: &LeftMargin=0
Set the resolution property (Value is expressed in DPI - Dots per inch).
Default is 72 dpi.
Servlet URL Parameter: "Resolution". Sample: &Resolution=72
6. Setting up text style in barcode image:
Set the showText properties. If this value is true, barcode data will be displayed with the barcode.
Default is true.
Servlet URL Parameter: "ShowText". Value: "t" (true), "f" (false). Sample: &ShowText=t
Set the textFont property. The font used to display text in barcode image.
Default is new Font("Arial", Font.PLAIN, 11).
Servlet URL Parameter: "TextFont". Value format: [font name]|[font style]|[font size]. Sample Values: &TextFont=Arial|Bold|12
7. With rotate property, you can display barcode horizontally or vertically.
Value can be
0 (Linear.ANGLE_0),
1 (Linear.ANGLE_90),
2 (Linear.ANGLE_180),
3 (Linear.ANGLE_270)

Default value is 0.
Servlet URL Parameter: "Rotate". Sample: &Rotate=0

7. How to Set Generated UPC-A Barcode Image Size?

Details for barcode size settings using Java barcode generator

http://www.barcodelib.com/java_barcode/barcode_symbologies/upca.html[2/2/2011 11:41:08 PM]


Java UPC-A Barcodes Generator for Java, J2EE, JasperReports

All Java Barcode Types/Symbologies

Codabar Identcode
Code 11 Leitcode
Code 2 of 5 Code 128
Code 39 GS1-128 / EAN-128
Code 93 MSI
EAN 8 Onecode
EAN 13 PLANET
ISBN POSTNET
ISSN RM4SCC (British Royal Mail 4-State Customer
ITF14 Barcode)
Interleaved 2 of 5 UPC-A
UPC-E

Data Matrix
PDF-417
QR-Code

Copyright 2010 BarcodeLib.com. Java Barcode, Barcode Java, Java Barcode Generator. All rights reserved.

http://www.barcodelib.com/java_barcode/barcode_symbologies/upca.html[2/2/2011 11:41:08 PM]

Vous aimerez peut-être aussi