.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Home > Java Barcode > Java QR Code Generator

Java QR Code Generator

Java QR Code Generation package to generate QR Code barcodes in Java applications.

  • The foreground color, the background color and the image format (png, png, gif, bmp) can be changed under image and color setting options.

  • Servlets, Applets, JavaBean and class library are provided.

  • Generate, create QR Code in Java class, Java bean, Servlet, EJB.

  • Java QR Code can be easily generated on any operating system with a JVM.

  • Generate QR Code barcodes in Jasper Reports, iReport & Eclipse BIRT

  • Java QR Code generator is compatible with JDK 1.4.0 or greater.

Java QR Code Generator - Overview

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

QR Code information:

QR Code:one of the most important 2D barcode types, is made up of a square area with a white background and black modules in it. It was first developed by Deso Wave Corporation in 1994 for manufacturing, and quickly became popular because of its fast readability and large storage capacity.

Available encoding data:

numeric digits:Max. 7,089 characters
alphanumeric:Max.4,296 characters
binary(8bits): Max. 2,953 bytes
kanji/kanna: Max. 1,817 characters

Varaible data length

The structure of an QR Code:

1. Version information
2. Format information
3. Data and error correction keys
4. Required patterns:consists of position, alignment, timing
5. Quiet zone


Java QR Code Generator Implementation to Generate QR Code in Java applications

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

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

// Set QRCode data text to encode
barcode.setData("Create-QR-Code-in-Java");

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

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

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


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

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

// Set QRCode data text to encode
barcode.setData("Create QRCode in EPS");

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

 

3. Generate & encode QR Code in html or jsp pages.

1. Under demo package, copy barcode folder and its contents to your tomcat.

2. Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=QRCodeEncodingData&TYPE=qrcode

3. 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=QRCodeEncodingData&TYPE=qrcode" />

 

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

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

QR Code Property Settings in Java Barcode Generator

QR Code Basic Settings

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

QR Code value to encode

QR Code Character Set:
  • Digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
  • 12 digits only, except the starting digits "978" or "979" only.

QR Code Special Settings

Properties Value
Comments
Property URL Options Default
dataMode
DATA-MODE
int

0

(DataMatrix.M_AUTO)

QRCode.M_AUTO (0): It allows encoding all 256 possible 8-bit byte values. This includes all ASCII characters value from 0 to 127 inclusive and provides for international character set support
QRCode.M_ALPHANUMERIC (1): It allows encoding alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : ).
QRCode.M_BYTE (2): It allows encoding byte data (default: ISO/IEC 8859-1).
QRCode.M_NUMERIC (3): It allows encoding numeric data (digits 0 - 9).
QRCode.M_KANJI (4): It allows encoding Kanji characters.

formatMode
FORMAT-MODE
int
0(DataMatrix.F-10X10)

Specifies the Data Matrix Format to use on that symbology. Valid values see class DataMatrix;

fnc1Mode
FNC1-MODE
int
IBarcode.
FNC1_NONE (0)

IBarcode. FNC1_ENABLE (1) value is to encode GS1 compatible QR Code barcode.

symbolCount
SYMBOL-COUNT
int
0

The symoblolCount property is for the sequence.

symbolIndex
SYMBOL-INDEX
int
0
The symbolIndex property is for the postion of current symbol in the secuence(start with 0)

processTilde

PROCESS-TILDE
true or false
true

Default value true is for using the tilde character "~" to specify special characters in the input data.

  • 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
    Strings from "~256" to "~299" are unused
  • 2-byte character (Unicode): ~6ddddd (character value from 00000 ~ 65535)
    Strings from "~665536" to "~699999" are unused
  • for GS1 AI Code:
    ~ai2: AI code with 2 digits
    ~ai3: AI code with 3 digits
    ~ai4: AI code with 4 digits
    ~ai5: AI code with 5 digits
    ~ai6: AI code with 6 digits
    ~ai7: AI code with 7 digits
  • ECI: ~7dddddd (valid value of dddddd from 000000 to 999999)
  • ~rp: Reader Programming (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~rpABCD1234".
  • ~m5: 05 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m5ABCD1234".
  • ~m6: 06 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m6ABCD1234".


ECL
ECL
int
QR Code.L(0)

QRCode Error Correction Level.

QRCode.ECL_L (0)
QRCode.ECL_M (1)
QRCode.ECL_Q (2)
QRCode.ECL_H (3)

structureAppend
STRUCTURE-APPEND
boolean
false If set the property to be ture, Structure Append is enabled.
parity
PARITY
int
0 The separation between the barcode and the supplement. Default is 15 pixel.

QR Code 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

QR Code Size Settings

Properties Value
Comments
Property URL Options Default
rotate

Rotate/div>
Degree0, 90, 180, 270
0 (Barcode.Rotate_0)

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

QR Code 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

QR Code 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