Java生成条码二维码

2018-06-18 02:46:40来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

一、概述

可用barcode4j或zxing等第三方库,推荐zxing。

barcode4j资料链接:http://barcode4j.sourceforge.net/

zxing资料链接:https://github.com/zxing/zxing

二、barcode4j

关键代码:

DataMatrixBean bean = new DataMatrixBean();
final int dpi = 800;
String format = "image/png";
ByteArrayOutputStream ous = new ByteArrayOutputStream();
BitmapCanvasProvider canvas = new BitmapCanvasProvider(ous, format, dpi,BufferedImage.TYPE_BYTE_BINARY, false, 0); 
bean.generateBarcode(canvas, info);
canvas.finish(); 

 支持的条码格式有:

  • Interleaved 2 of 5
  • ITF-14
  • Code 39
  • Code 128
  • EAN-128, GS1-128 (based on Code 128)
  • Codabar
  • UPC-A and UPC-E (with supplementals)
  • EAN-13 and EAN-8 (with supplementals)
  • POSTNET
  • Royal Mail Customer Barcode (Four State)
  • USPS Intelligent Mail (4-State Customer Barcode)

支持的二维码格式有:

  • PDF 417 (ISO/IEC 15438:2001(E))
  • DataMatrix (ISO/IEC 16022:2000(E))
  • QR Code (ISO/IEC 18004:2006(E)) (requires ZXing, available from CVS HEAD only)

可输出文件类型为:

  • SVG
  • EPS (Encapsulated PostScript)
  • Bitmap images (such as PNG or JPEG)
  • Java2D (AWT)
  • Text (for testing and debugging only)

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:sql判断字段是否为空

下一篇:SpringMVC入门就这么简单