Create PDF Document
Contents
[
Hide
]
Aspose.PDF for Java API lets Java application developers to embed PDF documents processing functionality in their applications. It can be used to create and read PDF files without the need of any other software installed on the underlying machine. Aspose.PDF for Java can be used in a variety of Java application types such as Desktop, JSP, and JSF applications.
How to create PDF File using Java
To create a PDF file using Java, the following steps can be used.
- Instantiate a Document object
- Add a Page to document object
- Create a TextFragment object
- Add TextFragment to Paragraph collection of the page
- Save the resultant PDF document
// Initialize document object
Document document = new Document();
//Add page
Page page = document.getPages().add();
// Add text to new page
page.getParagraphs().add(new TextFragment("Hello World!"));
// Save updated PDF
document.save("HelloWorld_out.pdf");