Monday, October 12, 2009

Java : Simple program to generate PDF File

This a simple program to generate PDF file. You need to download iText jar file to run this code. Get iText from

Here is the complete code.

/* */


import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

public class MyFirstPDFFile
public static void main(String arg[])throws Exception
Document document=new Document(PageSize.A4,50,10,10,10);

PdfWriter.getInstance(document,new FileOutputStream("MyFirstPDFFile.pdf"));;
document.add(new Paragraph("Simple and Easy Codes"));
document.add(new Paragraph(""));

No comments:

Post a Comment