# Edit HTML in PHP

> Import HTML, edit the generated presentation content, and export it to HTML5 in PHP.

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



## Edit HTML using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-java/) can import HTML content into presentation slides. You can then modify those slides by adding text, shapes, images, and other presentation elements before exporting the result to HTML5.

The export creates a new HTML5 document from the presentation; it does not modify the source HTML DOM in place. The following example imports an HTML file, adds a rectangle containing text to the first generated slide, and saves the result as HTML5.

## Edit HTML in PHP

Using [**Aspose.Slides for PHP via Java**](/slides/php-java/), you can import HTML, add a text shape to the generated slide, and export the modified content to HTML5 with a few lines of PHP code.

### PHP code for editing HTML

```php
$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);

    $htmlContent = file_get_contents("input.html");
    $presentation->getSlides()->addFromHtml($htmlContent);

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

    $presentation->save("output.html", SaveFormat::Html5);
} finally {
    $presentation->dispose();
}
```

## How to edit HTML 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)`.

Read the HTML content with `file_get_contents` and import it with `addFromHtml`.

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

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

## Edit Other Files
