How Do You Create PDF Files In Java?
Create a small Java program that demonstrates a few capabilities of iText library. You will learn how to create a document, add a pdf writer (listener), add some content to the created document, and last, but not least, close the document. This is just a quick intro to the creation of PDF files with Java, if you’re serious about automatic PDF creation using Java, then read Bruno Lowagie’s tutorial (link at the end). Make sure you have Java Runtime Environment, Eclipse and iText installed. In Eclipse create a new project, and name it what ever you might like at that particular moment. Then right click on the project name > Properties > Java Build Path > Add External JARs > Find your iText-2.1.5.jar > Press open > Press Ok. Create a document object: Document document = new Document(); Create a writer that listens to the document and directs a PDF stream to a file: FileOutputStream fos = new FileOutputStream(“c://ElloUniverse.pdf”); PdfWriter.getInstance( document, fos ); Open the pdf doc