Edit HTML in PHP

Import HTML into slides, modify the presentation content, and export the result to HTML5 with Aspose.Slides for PHP via Java.

Edit HTML using Aspose.Slides

Aspose.Slides for PHP via 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 , 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

$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

  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. Read the HTML content with file_get_contents and import it with addFromHtml.

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

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

Edit Other Files

You can also edit presentations in other supported formats.