Java Barcode Generator Color & 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


How to create, customize barcode image in Java web, desktop application?

  1. Download Java Barcode Generator library
  2. Install Java barcode generation library jar file into Java project
  3. Start to Create








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:
  1. Generate Barcode in Java - Detailed guide on how to print barcodes in Java programs with free trial package download
  2. Generate Barcode in Java Class - Detailed guide on how to create bar code image list in Java language
  3. Generate Barcode in Java Servlet - Guide on how to stream barcodes in Java web applications with Apache Tomcat
  4. Generate Barcode in iReport - Guide on how to print & embed barcode images in iReport with Java barcoder engine


How to print, customize 2d, 1d barcode colors using Java?

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!


Barcode bar & space module colors

Using OnBarcode Java Barcode Generator library, you can quickly customize and print barcode bar and space modules colors through methods setForeColor() for bar color and setBackColor for space color in Java application.

QRCode barcode = new QRCode();
barcode.setData("https://www.onbarcode.com");
barcode.setForeColor(Color.red);
barcode.setBackColor(Color.white);
barcode.drawBarcode("c://Output//OnBarcode.com//java-barcode-bar-space-colors.png");





Barcode with transparent background color

Using Java Barcode library, you can generate 2d and 1d barcode in PNG image with transparent background color.

To create a barcode with transparent background, you need set the background color alpha channel as 0 in Java program.

EAN13 barcode = new EAN13();
barcode.setData("123456789012");
barcode.setForeColor(Color.white);
barcode.setBackColor(new Color(0,0,0,0));
barcode.setTextColor(Color.white);
barcode.drawBarcode("c://Output//OnBarcode.com//java-barcode-background-transparent.png");





1D barcode text label color

You can customize the linear barcode human readable text color using method setTextColor() in Java application.

Code39 barcode = new Code39();
barcode.setData("CODE-39");
barcode.setForeColor(Color.red);
barcode.setBackColor(Color.white);
barcode.setTextColor(Color.red);
barcode.drawBarcode("c://Output//OnBarcode.com//java-barcode-text-color.png");





Print barcode in EPS format with CMYK color mode

You can draw and print a barcode in ESP image format with CMYK color mode applied using Java Barcode Generator library.
  • Set color mode as CMYK using method setUseCMYKInEPS(true)
  • Choose barcode output file format as EPS in method setOutputFileFormat(IBarcode.EPS)
EAN13 barcode = new EAN13();
barcode.setData("123456789012");
barcode.setForeColor(Color.blue);
barcode.setBackColor(Color.white);
barcode.setTextColor(Color.blue);
barcode.setUseCMYKInEPS(true);
barcode.setOutputFileFormat(IBarcode.EPS);
barcode.drawBarcode("C://Output//OnBarcode.com//java-barcode-eps-cmyk-color.eps");

The generated barcode in EPS format viewed by Acrobat





How to create barcode in raster image format (PNG, JPG) in Java?

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.

In Java class, call method setOutputFileFormat() with target image format input.
  • IBarcode.PNG, print barcode in PNG image format
  • IBarcode.GIF, draw barcode in GIF image format
  • IBarcode.JPG, output barcode in JPG (JPEG) image format
Code128 barcode = new Code128();
barcode.setData("Code-128");
barcode.setOutputFileFormat(IBarcode.PNG);
//barcode.setOutputFileFormat(IBarcode.GIF);
//barcode.setOutputFileFormat(IBarcode.JPG);
barcode.drawBarcode("C://Output//OnBarcode.com//java-barcode-raster-image-png.png");



High resolution (dpi) barcode image

To create a high quality barcode raster image for printing usage, you need make sure the generated barcode image resolution is higher than the printer's.

You can adjust the generated barcode image resolution property throguh
  • Method setResolution(): The value of the resolution should be larger than your printer's resolution.
barcode.setResolution(900);




How to create barcode in vector image format (SVG, PNG) in Java?

Top
Using Java Barcode Generator library, you can generate and output barcodes with vector image formats in Java application.
  • SVG: Scalable Vector Graphics (SVG) is a web-friendly vector file format. It is the only vector image supported by web browsers.
  • EPS: Encapsulated PostScript (EPS) is a Document Structuring Convention (DSC) conforming PostScript document format usable as a graphics file format.

To create a barcode in vector image format, you need choose the right output file format in barcode generation in Java code.
  • IBarcode.SVG, print barcode in SVG image format
  • IBarcode.EPS, draw barcode in ESP image format
Code128 barcode = new Code128();
barcode.setData("Code-128");
barcode.setOutputFileFormat(IBarcode.SVG);
//barcode.setOutputFileFormat(IBarcode.EPS);
barcode.drawBarcode("C://Output//OnBarcode.com//java-barcode-svg.svg");		












Common Asked Questions

Why is a barcode black and white in color?

2D and 1D Barcodes usually both are black bars and white space because this creates the highest contrast and is the easiest for barcode reader software and barcode scanners to decode. Using Java Barcode library, by default you will generate 2d and 1d barcodes in black and white in Java apps. You can customize the barcode module and space colors through method setForeColor(), and setBackColor() in Java codes.

What colors should barcodes be avoided?

When you are selecting colors for barcodes, it is important that you have selected colors with high contrast. If the bar and space module colors are both too light or too dark, the barcode scanner device or barcode reader software may not be able to decode.

Can barcodes be grey?

Yes. You can choose gray color as barcode bar modules color or space color. However you need make sure the space color and bar color have high contrast. In Java project, you can apply the printed barcode bar color using method setForeColor(), and barcode space color using method setBackColor().

Do QR Code colors matter?

QR codes don't have to be black and white in order to be scannable. You can choose right colors to increase brand recognition. However you need choose color combination with high contrast for QR Code bar and space module colors. Using Java Barcode Generator library, you can draw, customize and apply the generated QR Code bar color through method setForeColor(), and barcode space color through method setBackColor() in class com.onbarcode.barcode.QRCode.

What is SVG?

SVG stands for Scalable Vector Graphics. It is a vector image format which is perfect for barcode image rendering and viewing in web browser. Java Barcode Generator library supports QR Code and other 2d, 1d barcode encoding and generation in SVG image format in Java class.

Is SVG better than PNG?

SVG is a vector image format, which is considered a more advanced image file type than PNG. Both image formats can be used in web browser. OnBarcode Java Barcode library supports QR Code, Code 128, and 20+ 2d, linear barcodes generations in PNG and SVG image formats in Java applications.




































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