iText is a free and open source library for creating
PDF documents and generating Barcodes in Java.
This requires the library iText-5.0.2.jar to be in classpath.
The following example shows generating DataMatrix Barcode.
BarcodeDatamatrix datamatrix = new BarcodeDatamatrix();
datamatrix.generate("IText Barcode tutorials from BE THE CODER");
Image image = datamatrix.createImage();
//Add Barcode to PDF document
document.add(image);
document.close();
}