Java生成条码二维码
一、概述
可用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)
作者:马洪彪
出处:http://www.cnblogs.com/mahongbiao/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。