|
From: Kalyanaraman, K. (Dallas) <Ram...@Fi...> - 2010-08-19 22:13:04
|
Appreciate your help. I was under the impression that it will re-calculate while generating the barcode. If we can add an optional validation flag to validate the configuration before generation, that will be cool. I had some minor challenges where the barcode would scan in some scan guns and not in others, reducing the wide factor fixed that issue. Overall, this is a great piece of software when compared to using the embedded object font generated by Microsoft WEFT. -----Original Message----- From: Jeremias Maerki [mailto:de...@je...] Sent: Tuesday, August 17, 2010 1:02 AM To: bar...@li... Subject: Re: [Barcode4j-users] Help!! setting width and height for a Code39Bean Hi Kalyan The most likely problem is that you're using bean.setModuleWidth() twice: 1. bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); 2. bean.setModuleWidth(.05); So this overrides what you've set in the first step. 0.05mm are below the 0.19mm that are required by many Code39 specs I've found. See: http://barcode4j.sourceforge.net/2.0/symbol-code39.html UnitConv.in2mm(1.0f / 150) = 0.169333 That's also a bit under the recommendation. If you lower the resolution for the barcode bitmap to 120 dpi, you get a module width of 0.21mm. But for this to work in print, you still have to make sure the barcode bitmap is painted at 100% zoom (i.e. in its natural size). Otherwise the bars get scaled up or down again which may result in scanning problems. HTH On 16.08.2010 23:23:03 Kalyanaraman, Kalyan (Dallas) wrote: > I am trying to generate code39 barcodes using barcode4j. When I resize > the barcode using setModuleWidth and setBarHeight method, the generated > barcode is not scannable from scan gun. Please let me where iam going > wrong. > > Thanks a lot! > Kalyan > > > > int orientation = 0; > this.dpi = 150; > Code39Bean bean = new Code39Bean(); > bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar > //width exactly one pixel > bean.setWideFactor(3); > bean.setMsgPosition(HumanReadablePlacement.HRP_NONE); > bean.setBarHeight(5); > bean.setDisplayStartStop(true); > bean.setModuleWidth(.05); > bean.doQuietZone(false); > //orientation = setDimensions(request, bean); > BitmapCanvasProvider canvas = new BitmapCanvasProvider( > baout, "image/png", dpi, > BufferedImage.TYPE_BYTE_BINARY, false, orientation); > try { > bean.generateBarcode(canvas, barcode); > canvas.finish(); > //testSaveFile(((ByteArrayOutputStream) baout).toByteArray(), "writeFileTest"+barcode); > } finally { > baout.close(); > } > > Jeremias Maerki |