Resize PDF using PHP

Change PDF Page Size. Use Aspose.PDF for PHP via Java to modify PDF documents programmatically

Resize PDF Pages with PHP

In order to resize 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.

How to Resize PDF documents


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

  1. Load the source PDF file.
  2. Get the pages into the PageCollection object.
  3. Get a given page.
  4. Call the SetPageSize(..) method to update its dimensions.
  5. Call the Document class Save(..) method to generate the PDF file with updated page dimensions.

If you want to resize PDF files for your tasks, this solution can help. With this powerful Aspose.PDF PHP via Java library, you can update or change the page dimensions (size) of an existing files. This professional tool uses PHP to resize PDF effectively. The following example demonstrates how to change size of PDF document in PHP:

Resize PDF - PHP

This sample code shows how to Resize PDF Pages - PHP


    // Open document
    $document = new Document($inputFile);
      
    // Get page collection
    $pageCollection = $document->getPages();

    // Get particular page
    $page = $pageCollection->get_Item(1);

    // Set the page size as A4 (11.7 x 8.3 in) and in Aspose.Pdf, 1 inch = 72 points
    // So A4 dimensions in points will be (842.4, 597.6)
    $page.setPageSize(597.6, 842.4);

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

About Aspose.PDF for PHP via Java API

Aspose.PDF for PHP via Java is a powerful API designed to assist developers in creating, manipulating, and converting PDF documents programmatically. Aspose.PDF allows developers to create PDF documents from scratch or convert other document formats (such as HTML, XML, and images) to PDF. This is useful for generating reports, invoices, or any document type. It also recommends viewing a Documentation.