Hide URL in the 1d barcode so that when anyone scan it it will directly take to respective product page

941 Views Asked by At

I want to hide the URL in the 1D barcode so when anyone scan it, it will directly take me to the product page.

Is it possible, I have generated barcode now when I am scanning it, it is showing me barcode number but not the 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();
        }
}
1

There are 1 best solutions below

1
Rafa Gomez On

I would use QRCode for this.

Your barcode will be awesome long if you have long urls, which can be a problem depending what you want to do with it. You could use an url-shortener system, but again could be problematic.

Another problem is, that you need something triggering the call to the url.

Normally Barcode scanners are shipped with a software, which you can configure to do sth like this. Scanning a barcode is just "reading" its content. A barcode scanner can be seen as another form of keyboard.

So after you've read the content you will need some piece of software, that opens the browser and calls the url.

And think about the potential consumers...when you see a barcode, normally you don't think this is something you should scan to go to get some extra info, but that's the case with for ex. a QR Code. When you see it, you know (normally) what to expect.

I suppose there are some mobile apps, that after scanning a barcode, if they check the scanned string, and it's an url, they will give you the opportunity to navigate to this url. In this case only consumers with this type of app will be able to visit the page.