Aspose.BarCode  for Java

Java Barcode Generation & Recognition API

Create, & recognize barcodes of linear, 2D and postal types within any Java application.

  Download Free Trial

Aspose.BarCode for Java is a robust and reliable API providing the barcode generation and recognition features for Java applications. It supports the most established standards and specifications and allows developers to read 1D and 2D barcodes from different image files at any angles. Aspose.BarCode for Java renders barcode images in a variety of image formats with highly flexible imaging options. The library supports encoding and decoding over 60 barcode types and enables direct printing of barcode images.

Advanced Java Library Features

Customize Barcode Types and Appearance

The barcode API for Java allows developers to fine-tune the appearance of generated barcodes by specifying the barcode type, input text, font style, background and foreground colors, caption alignment and location, and other properties. You can modify the caption by setting its visibility for upper and lower captions, the font, colors, and alignment.

Barcode Generation Live Example

The barcode API enables developers to easily generate high-quality barcode images in their applications. It supports a wide range of barcode types, including widely used ones like QR Code and Code 128, as well as more specialized types like Aztec Code and Data Matrix. The API allows developers to customize the appearance of the generated barcodes, including the foreground and background colors, font, and caption alignment. Using the API, developers can easily generate 2D barcodes in the same way as they would generate one-dimensional barcodes.

Code to be executed - Java

// Create an instane of the BarcodeGenerator class
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR);

// Specify the code text

// Specify the X-dimension 
// the smallest width of the unit of BarCode bars or spaces

// Set codetext position

// Generate image
Generation result

Insert Barcodes into PDF Documents

The barcode library allows developers not only to create customized barcodes but also directly add generated images into PDF documents. You can first create barcode images using one of the supported raster formats and then insert them into a PDF file. The API enables adding barcodes without image compression and quality losses. It also provides functionality to modify barcode parameters and apperance before insertions or add the generated image into several document pages at once. Aspose.BarCode API can be used for high-quality printing of barcode images. Raster images have the standard resolution of 96 dpi, which does not suffice for this purpose. The API allows for setting a barcode image resolution of 300 or 600 dpi to print high-quality PDF documents.

Barcode Recognition Live Example

The Java barcode library is a powerful tool for working with barcodes in Java applications. One of its key features is the ability to read barcodes from different image file formats. The BarCodeReader class, which is the main class responsible for barcode recognition, supports many popular image formats, including BMP, PNG, TIFF, JPEG, and GIF. This makes it easy to integrate barcode recognition functionality into a wide range of applications.

Ready to recognize Recognizing Drop a file here or click to browse *

* By uploading your files or using the service you agree with our Terms of use and Privacy Policy.

Code to be executed - Java

// initialize reader with image & expected type
BarCodeReader reader = new BarCodeReader(var reader = new Aspose.BarCode.BarCodeReader("<file name>", DecodeType.AllSupportedTypes);

// read code
while ( {
    // print the code type & text
    System.out.println("Type: " + reader.getCodeType() + " Text: " + reader.getCodeText());

Recognition result

Scan Barcodes from PDF Documents

Besides reading barcodes from image files, the barcode library can be used to scan barcodes from PDF files. Developers can implement fast barcode detection in PDF documents with multiple pages. The API provides several ways to do it. The recommended way is to convert document pages to raster images and then apply barcode reading mechanisms. To render page contents into raster images is suggested as the easiest and the most efficient approach. Otherwise, barcode images can be first detected and extracted from the source PDF document. This method facilitates reading barcodes with original resolution. Aspose.BarCode API allows processing multipage PDF files to detect and recognize all barcodes presented in a document.

What People Are Saying

Don't just take our word for it. See what users have to say about APIs.

View Case Studies

Support and Learning Resources