我想隐藏一维条形码中的 URL,所以当有人扫描它时,它会直接带我到产品页面。
有可能吗,我现在在扫描时生成了条形码,它显示的是条形码编号而不是 URL。
try {
Code128Bean code128 = new Code128Bean();
code128.setHeight(15f);
code128.setModuleWidth(0.3);
code128.setQuietZone(10);
code128.doQuietZone(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BitmapCanvasProvider canvas = new BitmapCanvasProvider(baos, "image/x-png", 300, BufferedImage.TYPE_BYTE_BINARY, false, 0);
code128.generateBarcode(canvas, myString);
canvas.finish();
//write to png file
FileOutputStream fos = new FileOutputStream("C:\\Report\\"+image_name);
fos.write(baos.toByteArray());
fos.flush();
fos.close();
} catch (Exception e) {
// TODO: handle exception
}
}
String query="select * from itemdetails where barcodenumber='"+loc+"'";
ps = connection.prepareStatement(query);
rs=ps.executeQuery();
while(rs.next()){
Barcode_Image.createImage(rs.getString("websiteurl")+".png", rs.getString("barcodenumber"));
Barcode_PDF.createPDF(rs.getString("barcodenumber")+".pdf", rs.getString("barcodenumber"),rs.getString("websiteurl"));
System.out.println("Creating Barcode for "+rs.getString("barcodenumber"));
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(connection!=null){
try {
//connection.close();
}
catch (Exception e2) {
e2.printStackTrace();
}
}
if(ps!=null){
try {
//ps.close();
}
catch (Exception e2) {
e2.printStackTrace();
}
}