首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用速度模板生成二维码

如何使用速度模板生成二维码
EN

Stack Overflow用户
提问于 2017-06-20 19:28:16
回答 2查看 644关注 0票数 1

我正在使用velocity模板和java来创建电子邮件内容。我需要在邮箱模板中添加二维码,如何使用速度模板生成二维码?

EN

回答 2

Stack Overflow用户

发布于 2017-06-21 18:02:41

速度生成文本。二维码是一种图像。基本上,Velocity可以生成标签,但不能生成二维码本身。

您必须使用像QRGen这样的二维码生成器来生成二维码。

票数 1
EN

Stack Overflow用户

发布于 2018-09-08 01:24:47

代码语言:javascript
复制
String Cus_Name = (String) cmbCus_NameAdd.getSelectedItem();
String Cus_Id = lblCus_IDAdd2.getText();
String Odr_No = lblOrderNoAdd2.getText();
String Matir = lblMeterialAdd2.getText();
String amount = txtNoOfProductAdd.getText();
String date = lblDateAdd2.getText();
String time = lblTimeAdd2.getText();
String place = (String) cmbPlaceAdd.getSelectedItem();

String newLine = System.getProperty("line.separator");
String Details = "Customer Name - " + Cus_Name + "" + newLine + " Customer ID - " + Cus_Id + "" + newLine + " Order No - " + Odr_No + "" + newLine + " Material - " + Matir + "" + newLine + " Amount - " + amount + "" + newLine + " Date - " + date + "" + newLine + " Time - " + time + "" + newLine + " Place - " + place + "";

ByteArrayOutputStream out = QRCode.from(Details).to(ImageType.JPG).stream(); // this line creates QR code
File f = new File("C:\\Users\\Pulasthi Dinusha\\Desktop\\MainGui\\lib\\QR_Generator_Libs\\" + Odr_No + ".jpg");
FileOutputStream fos;
try {
    fos = new FileOutputStream(f);
    fos.write(out.toByteArray());
    fos.flush();

} catch (FileNotFoundException ex) {
    Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
    Logger.getLogger(test2.class.getName()).log(Level.SEVERE, null, ex);
}
ImageIcon iconLogo = new ImageIcon("C:\\Users\\Pulasthi Dinusha\\Desktop\\MainGui\\lib\\QR_Generator_Libs\\" + Odr_No + ".jpg");
// In init() method write this code
lblQRcodeAdd.setIcon(iconLogo);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44651816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档