1. Download iText-2.1.5.jar (You can google and get it)
2. Demo.java
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class Demo {
public static void main(String[] args) {
new Demo().createPDF();
}
public void createPDF(){
Document d = new Document (PageSize.A4);
try {
PdfWriter.getInstance(d, new FileOutputStream("sample.pdf"));
d.open ();
Paragraph p = new Paragraph ("Binod Kumar Suman,\n Bangalore, India");
d.add (p);
d.close ();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
System.out.println("******** PDF Created ***************");
}
}
Now check, you will get one pdf file sample.pdf
Friday, April 3, 2009
Subscribe to:
Post Comments (Atom)
Could you please provide RSS facility?
ReplyDeletenice article
ReplyDeleteHello Binod,
ReplyDeleteCan you help me regarding a problem??
That Problem is " how to display an image stored as blob type in mysql through iText pdf in JSP/Servlet"