Here is the code to generate a barcode based on the Id passed, the barcode is generated fine:
@Override
public byte[] generateBarcodeForId(String Id) throws VisitMastException{
BarcodeUtil util = BarcodeUtil.getInstance();
BarcodeGenerator gen;
ByteArrayOutputStream bao = null;
try {
bao = new ByteArrayOutputStream();
//Create the barcode bean
Code128Bean bean = new Code128Bean();
int dpi = 150;
//Configure the barcode generator
bean.setModuleWidth(UnitConv.in2mm(1.1f / dpi)); //makes the narrow bar, width exactly one pixel
bean.doQuietZone(true);
bean.setBarHeight(4);
//bean.setVerticalQuietZone(3);
bean.setQuietZone(0);
bean.setMsgPosition(HumanReadablePlacement.HRP_TOP);
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
bao, "image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, Id);
canvas.finish();
} catch (IOException e) {
throw new VisitMastException(VisitMastException.BAD_REQUEST,
messageSource.getMessage(CodeEnum.BARCODE_GENERATING_ERROR.getValue(), null, Locale.ENGLISH));
}
return bao.toByteArray();
}
This code places the human readable value above the barcode:
bean.setMsgPosition(HumanReadablePlacement.HRP_TOP);
The human readable value can be placed either at the bottom or top or neither. Is it possible to add the human readable value parallel to the barcode or next to it.
Also could we reduce the size of the human readable value?