2014-04-25 2 views
0

이 코드는 이미지 아래에 텍스트와 함께 바코드 이미지를 만듭니다. 이미지에서 텍스트를 제거해야합니다. Code39Bean에는이 기능을 비활성화 할 수있는 속성이 없습니다.Code39Bean의 바코드 이미지 아래의 텍스트 사용 안 함

public static ByteArrayOutputStream generateBarcodeImg(String inputId) 
      throws Exception { 

     ByteArrayOutputStream baos = new ByteArrayOutputStream(); 

     Code39Bean bean = new Code39Bean(); 
     final int dpi = 150; 

     /** 
     * Configure the bar-code generator and makes the narrow bar width 
     * exactly one pixel. 
     */ 
     bean.setModuleWidth(UnitConv.in2mm(1.0f/dpi)); 
     bean.setWideFactor(3); 
     bean.doQuietZone(false); 

     try { 

      /** Set up the canvas provider for monochrome PNG output. */ 
      BitmapCanvasProvider canvas = new BitmapCanvasProvider(baos, 
        BarCodeConstant.CONTENT_TYPE, dpi, 
        BufferedImage.TYPE_BYTE_BINARY, false, 0); 

      /** Generate the bar code. */ 
      bean.generateBarcode(canvas, inputId); 

      /** Signal end of generation. */ 
      canvas.finish(); 
     } catch (IOException e) { 
      logger.error(
        "Exception occured in BarcodeGeneration: generateBarcodeImg " 
          + e.getLocalizedMessage(), e); 
      throw new MobileResourceException(
        "Exception occured in BarcodeGeneration: generateBarcodeImg", 
        null); 
     } 
     return baos; 

    } 
} 

답변

1

당신은 "HumanReadablePlacement"속성을 통해 이미지에서 텍스트를 제거 할 수 있습니다

bean.setMsgPosition(HumanReadablePlacement.HRP_NONE); 

이 NONE으로 바코드의 사람이 읽을 수있는 텍스트가 표시되지 않습니다.