Work with Pages in PDF using PHP

Manage PDF pages in document programmaticaly using Aspose.PDF for PHP via Java Library

Most popular action with Pages in PHP

How to Insert pages to PDF Document using PHP

In order to add page in PDF file, we’ll use Aspose.PDF for PHP via Java API which is a feature-rich, powerful and easy-to-use document manipulation tool in php-java. Install Tomcat 9.0 version on any location, add Aspose.PDF.war, for more details check the GitHub page.

Add Page to PDF using PHP


To try the code in your environment, you need Aspose.PDF for PHP via Java.

  1. Create a Document object with the input PDF file.

  2. Call the PageCollection collection’s Insert method with specified index.

  3. Save the output PDF using the Save method.

Add New Page to PDF


    // Open document
    $document = new Document($inputFile);

    // Add page
    $document->getPages()->add();

    // Insert an empty page in a PDF
    $document->getPages()->insert(2);

    // Save output document
    $document->save($outputFile);
    $document->close();