Barcode 128 : Barcode « PDF RTF « Java






Barcode 128

import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Image;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.Barcode128;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

public class Barcode128Demo {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Barcode128.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();

      String code402 = "123456789012345" + Barcode128.FNC1;
      String code90 = "www.java2s.com" + Barcode128.FNC1;
      String code421 = "123456";
      String data = code402 + code90 + code421;

      Barcode128 shipBarCode = new Barcode128();
      shipBarCode.setX(0.75f);
      shipBarCode.setN(1.5f);
      shipBarCode.setChecksumText(true);
      shipBarCode.setGenerateChecksum(true);
      shipBarCode.setSize(10f);
      shipBarCode.setTextAlignment(Element.ALIGN_CENTER);
      shipBarCode.setBaseline(10f);
      shipBarCode.setCode(data);
      shipBarCode.setBarHeight(50f);

      Image imgShipBarCode = shipBarCode.createImageWithBarcode(cb, Color.black, Color.blue);

      document.add(imgShipBarCode);
    } catch (Exception e) {
      e.printStackTrace();
    }
    document.close();
  }

}

           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Example BarcodePDF417Example BarcodePDF417
2.Barcodes 39Barcodes 39
3.Barcodes 39 ExtBarcodes 39 Ext
4.Barcodes 128 (2)Barcodes 128 (2)
5.BarcodesEAN 13BarcodesEAN 13
6.BarcodesEAN SUPPBarcodesEAN SUPP
7.BarcodesInter25BarcodesInter25
8.BarcodePostnetBarcodePostnet
9.BarcodesPostnet 2BarcodesPostnet 2
10.BarcodeEAN: SUPP5BarcodeEAN: SUPP5