create barcode using java.


import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.Barcode128;
import com.itextpdf.text.pdf.PdfWriter;


public class BarCodeDemo {
public static void main(String[] args) throws Exception, DocumentException {
Document d=new Document(new Rectangle(PageSize.A4));
PdfWriter p=PdfWriter.getInstance(d, new FileOutputStream("E://demo.pdf"));
d.open();
Barcode128 b=new Barcode128();
b.setCode("12345678");
d.add(b.createImageWithBarcode(p.getDirectContent(), null, null));
d.close();
System.out.println("successfully created..");
}

}

download code related jar from below link : -

No comments: