Hi
 
I use the following class to create EAN13 barcodes for some JasperReports created PDF files. But all I tried so far never created a barcode including the text. All I get are just the bars. What am I missing?
I use itext-0.3.0.jar
 
 
import java.awt.Color;
import java.awt.Image;
import com.lowagie.text.pdf.Barcode;
import com.lowagie.text.pdf.BarcodeEAN;
import com.lowagie.text.pdf.BaseFont;
 
public class BCCreator {
 
 public static Image createEAN13(String code) {
  Image      ean13Image = null;
  BaseFont   font       = null;
  BarcodeEAN ean13      = new BarcodeEAN();
 
  try {
   font = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, true);
  }
  catch(Exception e) {
   e.printStackTrace();
  }
  ean13.setFont(font);
  ean13.setCodeType(Barcode.EAN13);
  ean13.setSize(10);
  ean13.setBaseline(40);
  ean13.setGuardBars(true);
  ean13.setCode(code);
  ean13Image = ean13.createAwtImage(Color.black, Color.white);
  return ean13Image;
 }
}
 
TIA

Reply via email to