{filelink=10340}
/***** Code de MesExemples.com *******/
import java.io.FileOutputStream;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.Barcode;
import com.itextpdf.text.pdf.BarcodePostnet;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
public class ExempleBarcodesPLANET {
public static void main(String[] args) {
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try {
PdfWriter pdf_writer = PdfWriter.getInstance(document,
new FileOutputStream("c:/ExBarcodesplanet.pdf"));
pdf_writer.setPdfVersion(PdfWriter.PDF_VERSION_1_7);
document.open();
PdfContentByte cb = pdf_writer.getDirectContent();
BarcodePostnet codePlanet = new BarcodePostnet();
codePlanet.setCode("50201402356");
codePlanet.setCodeType(Barcode.PLANET);
Image imagePlanet = codePlanet.createImageWithBarcode(cb, null,
null);
document.add(new Phrase(new Chunk(imagePlanet, 0, 0)));
}
catch (Exception err) {
err.printStackTrace();
}
document.close();
}
}