BarCode Control - generate barcode images
The BarCode Control provides a simple API to generate barcode
images. The control is invoked as follows:
ByteArrayOutputStream out = new ByteArrayOutputStream():
String barcode = "457989792";
boolean showName = false;
BarcodeStrategy strategy = BarcodeStrategy.CODE_39;
control.generateBarcode(barcode, showName, out, strategy);
The control streams the image to the supplied OutputStream. This
output stream can be to a byte array, as shown in the code
snippet. It could equally well be the output stream associated
with a HttpServletResponse - thereby enabling you stream the image to a
web browser. This is the approach taken by the Java Page Flow
sample that accompanies the control - it uses a Java Page Flow action
to stream a GIF image back to a browser.
The barcode string is the encoding of the barcode as issued by barcode
providers. The strategy is the type of encoding used by the
barcode. Supported encodings include Code 39, Extended Code 39,
Codabar, Code 128, Interleaved 25 and MSI.
The showName boolean states whether to display the barcode string under
the barcode image.
The control implementation uses the JBarcodeBean written by Dafydd
Walters and which is hosted here on SourceForge.