利用barcode4j生成条形码
2018-07-20 来源:open-open
package k.barcode; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import org.krysalis.barcode4j.impl.code39.Code39Bean; import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider; import org.krysalis.barcode4j.tools.UnitConv; public class Barcode { public static void main(String[] args) { try { //Create the barcode bean Code39Bean bean = new Code39Bean(); final int dpi = 150; //Configure the barcode generator bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar //width exactly one pixel bean.setWideFactor(3); bean.doQuietZone(false); //Open output file File outputFile = new File("d:\\\\out.png"); OutputStream out = new FileOutputStream(outputFile); try { //Set up the canvas provider for monochrome JPEG output BitmapCanvasProvider canvas = new BitmapCanvasProvider( out, "image/png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0); //Generate the barcode bean.generateBarcode(canvas, "A123456"); //Signal end of generation canvas.finish(); } finally { out.close(); } } catch (Exception e) { e.printStackTrace(); } } }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:iOS应用内发送邮件
最新资讯
热门推荐