Edit PDF in PHP

Import PDF pages, add presentation elements, and export the result to PDF with Aspose.Slides for PHP via Java.

Edit PDF in PHP

Using Aspose.Slides for PHP via Java , you can import PDF pages, add a text shape to the first generated slide, and export the modified content to PDF with a few lines of PHP code.

PHP code for editing PDF

$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);
    $presentation->getSlides()->addFromPdf("input.pdf");

    $slide = $presentation->getSlides()->get_Item(0);
    $shape = $slide->getShapes()->addAutoShape(
        ShapeType::Rectangle, 10, 10, 100, 50);
    $shape->getTextFrame()->setText("New text");

    $presentation->save("output.pdf", SaveFormat::Pdf);
} finally {
    $presentation->dispose();
}

Edit PDF using Aspose.Slides

Aspose.Slides for PHP via Java can import PDF pages into a presentation, let you add or modify presentation elements, and export the result as a new PDF document.

This workflow does not edit the source PDF in place. The following example imports a PDF, adds a rectangle containing text to the first imported page, and saves the result as a new PDF file.

How to edit PDF in PHP

  1. Install Aspose.Slides for PHP via Java. See Installation.
  2. Configure Aspose.Slides in your PHP project.
  3. Create a Presentation and remove its default slide with removeAt(0).
  4. Import the PDF pages with addFromPdf.
  5. Access the first imported slide, add a rectangle with addAutoShape, and set its text with setText.
  6. Call save with the output file path and SaveFormat::Pdf.

Built with Aspose.Slides

Edit PPTX Files Online

The free Aspose.Slides Editor app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own PPTX files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides handles your files before you write code.
  • Upload your PPTX files and edit them instantly.
  • Save and download the edited file.

Edit Other Files

You can also edit presentations in other supported formats.