.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Home > Java Barcode > Java Postnet Generator

Java Postnet Generator

Java Postnet Generation package to generate Postnet linear barcodes in Java applications.

  • Completely developed in Java.

  • Orientation allows for changes among 0, 90, 180 or 270 degrees

  • Postnet Java Barcode Generator package contains Applet, Servlet, and Class Library, which will facilitate the creation of Postnet in Java projects, Java class, Java sever side apps.

  • Java Postnet allows easy encapsulation, integration and customization with JavaBean conforming to a particular convention under a developmental environment.

  • Java Postnet barcode generation package allows the foreground color, the background color and the image format (png, png, gif, bmp) to be changed under image and color setting options.

Java Postnet Generator - Overview

Java Postnetr generator is a mature and reliable Java barcode generation component for creating Postnet barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects. High-quality Postnet barcode images can be drawn and printed into GIF, BMP, PNG, JPEG/JPG & TIFF formats with Java Postnetbarcode generator.


Postnet information:


Postnet: short for Postal Numeric Encoding Technique, is a barcode symbology used by the United States Postal Service to assist in directing mail. The ZIP Code or ZIP+4 code is encoded in half- and full-height bars.


Available encoding data:

numeric data 0-9.

5, 6, 9, 11digits length only

The structure of a Postnet:

1. Frame bar, encoded as a single 1.
2. 5, 9, or 11 data characters properly encoded.
3. Check digit.
4. Final frame bar, encoded as a single 1.


Java Postnet Installation & Implementation

1. Generate Postnet in Java class with the changing of barcode properties.

// Create Java POSTNET object
Postnet barcode = new Postnet();

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

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

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

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

2. Generate & encode Postnet to EPS with changing the values concerned.

// Create Java Postnet object
Postnet barcode = new Postnet();

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

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

3. Generate & encode Postnet 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=987654321&TYPE=postnet

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

<imgsrc="http://YourDomain:Port/barcode/barcode?DATA=987654321&TYPE=postnet" />

4. Two ways to set the width and height of generated barcode Postnet image.

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

Postnet Property Settings in Java Barcode Generator

Postnet Basic Settings

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

Postnet value to encode

Postnet Character Set:
  • Digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
  • 5, 6, 9, 11 digits only, excluding the last checksum digit

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

addCheckSum property is not applied here. Java Barcode will automatically add one checksum character.

Postnet Special Settings

Properties Value
Comments
Property URL Options Default
ShortTallRatio
SHORT-TALL-RATIO
float
0.4of Short bar vs tall bar (Y) ratio

Postnet 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

Postnet 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

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

Postnet 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

Postnet 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