Hello World Java Example
Hello World Example
A “Hello World” example is traditionally used to introduce features of a programming language or software with a simple use case.
Aspose.PDF for Java API empowers Java application developers to create, read, edit and manipulate PDF files in their applications. It lets you read and convert several different file types to and from PDF file format. This Hello World article shows how to create a PDF file in Java using Aspose.PDF for Java API. After installing Aspose.PDF for Java in your environment, you can execute the below code sample to see how Aspose.PDF API works.
Below code snippet follows these steps:
- 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
The following code snippet is a Hello World program to exhibit the working of Aspose.PDF for Java API.
// 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");