PDF Java Tutorial

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    BaseFont bf = BaseFont.createFont("putr8a.afm", "", BaseFont.EMBEDDED);
    Font font = new Font(bf, 12);
    document.add(new Paragraph("0123456789\nabcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXZ",
        font));
    bf = BaseFont.createFont("cmr10.afm", "", BaseFont.EMBEDDED);
    font = new Font(bf, 12);
    document.add(new Paragraph("0123456789\nabcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXZ",
        font));
    document.close();
  }
}