How to generate bar code for each items in java
package com.proximotech.etrade.utils;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.Barcode;
import com.lowagie.text.pdf.Barcode128;
import com.lowagie.text.pdf.BarcodeEAN;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class BarcodeCreator {
public String barcodeToPdf() throws FileNotFoundException, DocumentException{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
"lumina730.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCode("1439112001143");
Paragraph p = new Paragraph();
// CODE 128
document.add(new Paragraph("Barcode 128"));
Barcode128 code128 = new Barcode128();
code128.setCode("9112001 Deepak");
document.add(code128.createImageWithBarcode(cb, null, null));
document.add(p);
document.close();
return null;
}
public static void main(String[] javacode) throws Exception {
}
}
http://javabelazy.blogspot.in/
No comments:
Post a Comment
Your feedback may help others !!!