BarCode with Random Number.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.Barcode128;
import com.itextpdf.text.pdf.PdfWriter;
import java.awt.Desktop;
import java.io.File;
import java.util.Random;
//import com.lowagie.text.Document;
//import com.lowagie.text.DocumentException;
//import com.lowagie.text.PageSize;
//import com.lowagie.text.Paragraph;
//import com.lowagie.text.Rectangle;
//import com.lowagie.text.pdf.Barcode128;
//import com.lowagie.text.pdf.PdfWriter;
public class BarCode128 {
public static void main(String[] args) throws FileNotFoundException, DocumentException {
Document document = new Document(new Rectangle(PageSize.A4));
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("h:/Naveen3.pdf"));
Random r=new Random();
int ran=r.nextInt(99999);
String newStr = "NAVJYOTI" + ran ;
document.open();
document.add(new Paragraph("Barcode Test"));
Barcode128 code128 = new Barcode128();
code128.setGenerateChecksum(true);
code128.setCode(""+newStr);
document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
document.close();
}
}