首页 新闻 会员 周边 捐助

barcode4j生成的条形码有小白点,识别不了

0
[待解决问题]

private static void generateCode128Barcode(String filePath, String code, Double height, Double moduleWidth, Double fontSize, Boolean isShowNo) {
File file = new File(filePath);
Code128Bean bean = new Code128Bean();
final int dpi = 150;

//barcode
bean.setModuleWidth(moduleWidth);
bean.setHeight(height);
bean.doQuietZone(true);
bean.setQuietZone(2);//两边空白区
bean.setVerticalQuietZone(0.5);
//human-readable
bean.setFontName("Helvetica");
bean.setFontSize(fontSize);

// 不展示单号
if (!isShowNo){
bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
}
// bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
OutputStream out = null;
try {
out = new FileOutputStream(file);
BitmapCanvasProvider canvas = new BitmapCanvasProvider(out,"image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);

bean.generateBarcode(canvas, code);
canvas.finish();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null)
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

Xson的主页 Xson | 菜鸟二级 | 园豆:202
提问于:2017-05-22 16:01
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册