# Edit PDF in PHP

> Import PDF content, add presentation elements, and export the result to PDF in PHP.

Source: https://products.aspose.com/slides/php-java/editor/pdf/
Updated: 2026-07-20



## Edit PDF using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-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.

## Edit PDF in PHP

Using [**Aspose.Slides for PHP via Java**](/slides/php-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

```php
$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();
}
```

## How to edit PDF in PHP

Install **Aspose.Slides for PHP via Java**. See [**Installation**](https://docs.aspose.com/slides/php-java/installation/).

Configure Aspose.Slides in your PHP project.

Create a `Presentation` and remove its default slide with `removeAt(0)`.

Import the PDF pages with `addFromPdf`.

Access the first imported slide, add a rectangle with `addAutoShape`, and set its text with `setText`.

Call `save` with the output file path and `SaveFormat::Pdf`.

## Edit Other Files
