日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

OkapiBarcode生成条形码

發布時間:2024/9/21 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OkapiBarcode生成条形码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

1.簡介

OkapiBarcode 是一個 Java 的條形碼編碼程序,支持超過 50 種編碼標準

git地址:https://github.com/woo-j/OkapiBarcode

官網:http://www.okapibarcode.org.uk/Excel.aspx

2.maven引入

<dependency><groupId>uk.org.okapibarcode</groupId><artifactId>okapibarcode</artifactId><version>0.1.5</version> </dependency>

3.示例代碼

Code32 barcode=new Code32(); //字體樣式 barcode.setFontName("Monospaced"); //設置字體大小 barcode.setFontSize(16); //設置模塊寬度(默認值是1)。 barcode.setModuleWidth(2); //設置默認的bar高度(單行高度)(默認值是3) barcode.setBarHeight(50); //設置文本的位置 barcode.setHumanReadableLocation(HumanReadableLocation.BOTTOM); Date date=new Date(); //設置內容 barcode.setContent("1234");int width = barcode.getWidth(); int height = barcode.getHeight();//創建一個圖片流 BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);//使用Graphics2D繪制圖片 Graphics2D g2d = image.createGraphics(); g2d.setPaint(Color.WHITE); g2d.fillRect(0, 0, width, height);//創建一個渲染器 Java2DRenderer renderer = new Java2DRenderer(g2d, 1, Color.WHITE, Color.BLACK); renderer.render(barcode); //將圖片輸出到一個文件里面 ImageIO.write(image, "png", new File("C:\\Users\\zwq\\Desktop\\img\\"+ RandomUtils.nextInt(0,100)+".png"));

這只是簡單的應用

結果:

這樣就可以利用手機進行掃描出條形碼的數據了

轉載于:https://my.oschina.net/u/2534361/blog/1810594

總結

以上是生活随笔為你收集整理的OkapiBarcode生成条形码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。