Hello World PHP via Java Example

Hello World Example

A “Hello World” example is typically used to demonstrate the basic features of a programming language or software with a straightforward use case.

Aspose.PDF for PHP via Java API enables developers to create, read, edit, and manipulate PDF files within their Java applications. It supports reading and converting various file types to and from the PDF format. This Hello World article shows how to create a PDF file using Aspose.PDF for PHP via Java API. After installing Aspose.PDF for PHP via Java in your environment, you can execute the below code sample to see how Aspose.PDF API works.

Below code snippet follows these steps:

  1. Instantiate a Document object
  2. Add a Page to document object
  3. Create a TextFragment object
  4. Add TextFragment to Paragraph collection of the page
  5. Save the resultant PDF document

The following code snippet is a Hello World program to exhibit the working of Aspose.PDF for PHP via Java API.

    $document = new Document();    
    $page = $document->getPages()->add();
    $textFragment = new TextFragment("Hello World!");    
    $page->getParagraphs()->add($textFragment);
    $document->save($outputFile);