This a simple program to generate PDF file. You need to download iText jar file to run this code. Get iText from http://www.lowagie.com/iText/download.html
Here is the complete code.
/* MyFirstPDFFile.java */
import java.io.*;
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.open();
document.add(new Paragraph("Simple and Easy Codes"));
document.add(new Paragraph("http://simpleandeasycodes.blogspot.com/"));
document.close();
}
}
Here is the complete code.
/* MyFirstPDFFile.java */
import java.io.*;
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.open();
document.add(new Paragraph("Simple and Easy Codes"));
document.add(new Paragraph("http://simpleandeasycodes.blogspot.com/"));
document.close();
}
}