BarCode.jar包 ,将内容转换为1维条码
public static byte [] createBarCode(String content){ if(content==null){ return null; } ByteArrayOutputStream out=null; try { out=new ByteArrayOutputStream(); Code39Bean bean = new Code39Bean(); final int dpi = 150; bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); bean.setWideFactor(3); bean.doQuietZone(false); BitmapCanvasProvider canvas = new BitmapCanvasProvider(out// ,"image/jpeg"// ,dpi// ,BufferedImage.TYPE_BYTE_BINARY// ,false// ,0); bean.generateBarcode(canvas, content); canvas.finish(); return out.toByteArray(); } catch (IOException e) { throw new RuntimeException("创建条形码失败!"); }finally{ if(out!=null){ try { out.close(); } catch (IOException e) { throw new RuntimeException("资源不能正常关闭!"); } } } }