我正在使用velocity模板和java来创建电子邮件内容。我需要在邮箱模板中添加二维码,如何使用速度模板生成二维码?
发布于 2017-06-21 18:02:41
速度生成文本。二维码是一种图像。基本上,Velocity可以生成标签,但不能生成二维码本身。
您必须使用像QRGen这样的二维码生成器来生成二维码。
发布于 2018-09-08 01:24:47
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);https://stackoverflow.com/questions/44651816
复制相似问题