Create PDF Document

Aspose.PDF for PHP via Java API lets 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 PHP via Java can be used in a variety of application types such as Desktop, JSP, and JSF applications.

How to create PDF File using PHP via Java

To create a PDF file using PHP via Java, the following steps can be used.

  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

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