I need to auto generate bar codes that when a certain quantity is inputted in a `TextBox`

StackOverflow https://stackoverflow.com/questions/22440510

  •  15-06-2023
  •  | 
  •  

Question

I need to auto generate bar codes that when a certain quantity is input in a TextBox.

FOR EXAMPLE:
the max value of ProductID in the database is 10000018. When I input 2 in the TextBox it will generate bar code images with the value 10000019, 10000020.

Any help will be greatly appreciated.

import com.aspose.barcode.BarCodeBuilder;
import com.aspose.barcode.Symbology;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;

String strBaseFolder = "C:\\users\\ronjonathan\\desktop\\barcode\\";

String query = "Select MAX(ProductID) from tblindividualproduct";
try
{
    int i=0;
    // Generate barcode image
    BarCodeBuilder builder = new BarCodeBuilder();
    builder.setSymbologyType(Symbology.Code128);

    pst=con.prepareStatement(query);    
    rs=pst.executeQuery();
    if(rs.next()){
        for(i=rs.getInt(1); i<=Integer.parseInt(txtBarcode.getText()); i++){
            builder.setCodeText(Integer.toString(i));
            String strBarCodeImageSave = ""+i+".jpg";
            builder.save(strBaseFolder + strBarCodeImageSave);
Was it helpful?

Solution

It should be:

if(rs.next()){
    int MAX = rs.getInt(1);
    for(i=1; i <= Integer.parseInt(txtBarcode.getText()); i++){
        ...
        String strBarCodeImageSave = ""+(i+MAX)+".jpg";
        ...
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top