Merge HTML Files in PHP

Combine HTML content with Aspose.Slides for PHP via Java.

Merge HTML to HTML in PHP

Using Aspose.Slides for PHP via Java , you can import two HTML files and save their combined presentation content as HTML with a few lines of PHP code.

PHP code for merging HTML to HTML

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

    $firstHtmlContent = file_get_contents("file1.html");
    $presentation->getSlides()->addFromHtml($firstHtmlContent);

    $secondHtmlContent = file_get_contents("file2.html");
    $presentation->getSlides()->addFromHtml($secondHtmlContent);

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

Merge HTML to HTML using Aspose.Slides

Aspose.Slides for PHP via Java can import content from multiple HTML files into a Presentation and export the resulting slides as a single HTML document. The imported text, images, and supported formatting become presentation content before the final HTML export.

How to merge HTML files in PHP

  1. Install Aspose.Slides for PHP via Java. See Installation.
  2. Configure Aspose.Slides in your PHP project.
  3. Create a Presentation instance and remove its default slide.
  4. Read the HTML files with file_get_contents and import their content with addFromHtml.
  5. Call save with the output file path and SaveFormat::Html5.

Built with Aspose.Slides

Merge HTML Files Online

The free Aspose.Slides Merger 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 HTML files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides merges files before you write code.
  • Upload several HTML files and combine them into one.
  • Download the merged result as one file.

Merge Other Files

You can also combine files in other supported formats.