The following example demonstrates how to create a simple PDF form using iText.
- Download the latest version of iText (v 1.4.7).
- The following piece of code can be used to generate a simple pdf with some text on it
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class TestiText {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("c:\\test.pdf"));
document.open();
document.add(new Paragraph("iText Works :)"));
} catch (DocumentException de) {
de.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
document.close();
}
}TestiText.java Paragraph is one of the page elements in iText a listing of the page elements can be found here.
No comments:
Post a Comment