原創(chuàng)|使用教程|編輯:王香|2017-11-21 14:03:03.000|閱讀 407 次
概述:專業(yè)的條碼組件,專為開(kāi)發(fā)人員在Java應(yīng)用程序(J2SE和J2EE)上生成、讀取和掃描1D、2D條形碼而設(shè)計(jì),本文介紹了如何通過(guò)Spire.Barcode在Java中生成QR碼。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷售中 >>
相關(guān)鏈接:
本教程提供了用于在Java中生成QR碼的代碼示例。
package GenerateBarcode; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import com.spire.barcode.BarCodeGenerator; import com.spire.barcode.BarCodeType; import com.spire.barcode.BarcodeSettings; import com.spire.barcode.QRCodeECL; import com.sun.javafx.print.Units; public class QR_Code { public static void main(String[] args) throws IOException { //create an instance of BarcodeSetteings BarcodeSettings settings = new BarcodeSettings(); //set barcode type settings.setType(BarCodeType.QR_CODE); //set barcode data settings.setData("ABC 123456789"); //set dispaly text settings.setData2D("ABC 123456789"); //show text on bottom settings.setShowTextOnBottom(true); //set the border invisible settings.hasBorder(false); //set width of the barcode module settings.setX(2); //set the error correction level settings.setQRCodeECL(QRCodeECL.M); //create BarCodeGenerator object based on settings BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings); //generate image data and store in BufferedImage instance BufferedImage bufferedImage = barCodeGenerator.generateImage(); //save to image ImageIO.write(bufferedImage,"png",new File("QR_CODE.png")); System.out.println("Complete!"); } }
輸出:
點(diǎn)擊下載Spire.Barcode for JAVA
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn