Java Barcode Generation & Image Settings
How to Create Barcodes in Java and Adjust Image Settings with Java Library
Generate, draw barcodes using Java Class and customize image settings
- Developed in Java with full support for JDK 1.4.2 and above versions
- Simple to generate barcode images on any operating system with Java Virtual Machine installed
- Creating Java QR Code, Java PDF-417, Java Code 39, Code 128 and other linear, 2D barcodes
- Easy to print & implement high-quality barcodes using Java Class, Jasper Report, iReport, etc
- Java Servlet included to stream Gif, Png, Jpeg, EPS barcode images in Java Web application
- API with Flexible Java barcode settings to adjust image format, color, rotation, resolution and more
- Java class sample codes are provided for valid barcode output of high quality
- Mature Java barcode implementing SDK presented with a single Jar file
OnBarcode Java Barcode Generator is a professional and reliable library SDK which enables developers to draw, print best barcodes (linear & bidimensional) in various Java programs, ranging from Java Class, Java Web application (JSP, Servlet, html page), Jasper Report, iReport, Eclipse BIRT and Oracle Report. In addition, plenty of barcode settings are provided so you can customize image properties through Java coding.
Besides this imaging tutorial, OnBarcode also provides other Java barcode implementation examples:
- Generate Barcode in Java - Detailed guide on how to print barcodes in Java programs with free trial package download
- Generate Barcode in Java Class - Detailed guide on how to create bar code image list in Java language
- Generate Barcode in Java Servlet - Guide on how to stream barcodes in Java web applications with Apache Tomcat
- Generate Barcode in iReport - Guide on how to print & embed barcode images in iReport with Java barcoder engine
How to Use Java Class to Set Colorful Barcodes
Top
If you don't want to create a typical black-and-white barcode image, OnBarcode Java Barcode Generator gives you the option to change barcode foreground color (bar color), background color, and the text color (color for the human readable text).
This can be easily achieved through some Java class coding. To start with, please create a new Java Class Project and add OnBarcode Java Library (jar) to your module libraries. Follow the sample code below, and you will create a colorful barcode!
If you're not sure what data to input, please refer to this online
Java Barcode Data Encoding Tutorial, which explains GS1 data encoding (numbers / alphanumeric), Unicode, zip code for postal barcode, or other special character (ASCII) barcode input.
Code128 barcode= new Code128();
barcode.setData("Code128");
//Customize Code 128 barcode image size
barcode.setX(2);
barcode.setY(60);
barcode.setAutoResize(false);
barcode.setShowText(true);
//Ajust Code 128 barcode background color, bar color and text color
barcode.setForeColor(Color.red);
barcode.setBackColor(Color.green);
barcode.setTextColor(Color.blue);
//Barcode output method here
barcode.drawBarcode("C://java-code128.gif");
How to Create Java Barcodes in Png, Gif, Jpeg Formats
Top
This Java Barcode Generator provides a PNG image format at default for generated barcodes. Of course, you can also opt to create barcode images in Gif and Jpeg file formats. This can easily be done through Java programming. The Java class sample code is provided here for you.
Below is the java sample code for encoding Interleaved 2 of 5. Users can compile more codings to adjust barcode sizing (width & height), file formats (bitmap, bmp, gif, jpg, tiff, png), check digit calculation, or other barcode value.
Interleaved25 barcode = new Interleaved25();
barcode.setData("123456");
barcode.setX(2);
//Set Interleaved 2 of 5 barcode image formats into Gif
barcode.setImageFormat(0);
barcode.drawBarcode("C://java-interleaved25.gif");
/*
//Set Interleaved 2 of 5 barcode image formats into Jpeg
barcode.setImageFormat(1);
barcode.drawBarcode("C://java-interleaved25.jpg");
//Set Interleaved 2 of 5 barcode image formats into Png
barcode.setImageFormat(2);
barcode.drawBarcode("C://java-interleaved25.png");
*/
Besides barcode color and image format, OnBarcode Java SDK also provides functions to customize barcode rotation rate, image resolution, barcode bar alignment, Font Style & Size & Margin, etc. You can refer to the sample code blow for Java UPC-A barcoding and make adjustment if necessary.
UPCA barcode = new UPCA();
barcode.setData("55555999991");
barcode.setX(1);
//Set UPC-A barcode bar alignment to center (1)
barcode.setBarAlignment(1);
//Set true to display human-readable text for barcode
barcode.setShowText(true);
//Customize UPC-A barcode font style
barcode.setTextFont(new Font("Arial", Font.BOLD , 11));
barcode.setTextMargin(8);
//Generate and save UPC-A barcode to Hard Drive C
barcode.drawBarcode("C://java-upca.gif");
Java Barcode Generation Guide for Linear & 2D Barcode Types
Top
Java Barcode Library SDK - Barcodes Generation