import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.BarcodePDF417;
import com.lowagie.text.pdf.PdfWriter;
public class ExampleBarcodePDF417 {
public static void main(String[] args) {
try {
BarcodePDF417 pdf417 = new BarcodePDF417();
pdf417.setText("www.java2java.com has some demo for PDF");
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ExampleBarcodePDF417.pdf"));
document.open();
Image img = pdf417.getImage();
img.scalePercent(50, 50 * pdf417.getYHeight());
document.add(img);
document.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
|