Java 禁用Code39Bean中条形码图像下方的文本
此代码创建条形码图像以及图像下方的文本。 我需要从图像中删除文本。 Code39Bean没有任何属性来禁用此功能Java 禁用Code39Bean中条形码图像下方的文本,java,Java,此代码创建条形码图像以及图像下方的文本。 我需要从图像中删除文本。 Code39Bean没有任何属性来禁用此功能 public static ByteArrayOutputStream generateBarcodeImg(String inputId) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Code39Bean bean
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;
}
}
您可以通过HumanReadablePlacement属性从图像中删除文本:
bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
这会将条形码的人类可读文本抑制为无。您可以通过HumanReadablePlacement属性从图像中删除文本:
bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
这会将条形码的人类可读文本抑制为无