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 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();
}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.
How to edit HTML in PHP
- Install Aspose.Slides for PHP via Java. See Installation.
- Configure Aspose.Slides in your PHP project.
- Create a
Presentationand remove its default slide withremoveAt(0). - Read the HTML content with
file_get_contentsand import it withaddFromHtml. - Access the first generated slide, add a rectangle with
addAutoShape, and set its text withsetText. - Call
savewith the output file path andSaveFormat::Html5.
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.