Tuesday, December 04, 2007

Writing pdf file using java

Librery used iText

// Step 1: Create an instance of com.lowagie.text.Document:

Document document = new Document();

//Step 2: Create a Writer (for instance com.lowagie.text.pdf.PdfWriter)
//that listens to this document and
//writes the document to the OutputStream of your choice:

PdfWriter.getInstance(document, new FileOutputStream("HelloWorld.pdf"));

//Step 3: Open the document:


//Step 4: Add content to the document:

document.add(new Paragraph("Hello World"));

//Step 5: Closes the document:


syntax highlighted by Code2HTML, v. 0.9.1

check other tutorials

No comments: