I had a piece of code which was working in java version 1.5 but when i recently updated the java version to 1.6, the application was generating unscannable barcodes.
When compared with previous version, the barcodes were slightly different. Thickness of certain lines also changed
Please help
Code Below::
String str = (String)TSFDataChannel.getValue(httpservletrequest,"BC");
File file = new File("mybarcode_"+Helpers.stripGarbage(str)+".png");
OutputStream out = new FileOutputStream(file);
Barcode barcode;
try {
Code128Bean bean = new Code128Bean();
final int dpi = 500;
//Configure the barcode generator
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
bean.setFontSize(0); //width exactly one pixel
bean.doQuietZone(false);
//bean.setVerticalQuietZone(UnitConv.pt2mm(3));
bean.setHeight(1.5);
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
out,"image/png", dpi, BufferedImage.TYPE_BYTE_BINARY, true, 0);
//Generate the barcode
bean.generateBarcode(canvas, str);
//Signal end of generation
canvas.finish();
httpservletresponse.setContentType("APPLICATION/OCTET-STREAM");
String disHeader = "Attachment;Filename=mybarcode_"+str+".png" ;
httpservletresponse.setHeader("Content-Disposition", disHeader);
FileInputStream fileInputStream = new FileInputStream(file);
int i;
while ((i=fileInputStream.read())!=-1)
{
httpservletresponse.getOutputStream().write(i);
}
httpservletresponse.getOutputStream().flush();
httpservletresponse.getOutputStream().close();
fileInputStream.close();
} catch (Exception e1) {
e1.printStackTrace();
} finally{
file.delete();
out.close();
}