Merge HTML in PHP

High-speed and cross-platform PHP library for merging HTML files using PHP code

Merge HTML to HTML using Aspose.Slides

Aspose.Slides for PHP via Java is a powerful PHP library used to create, convert, merge, and manipulate presentations, HTML files, and other documents. When you merge HTML to HTML, you are effectively combining the contents from 2 documents to obtain one HTML file. Aspose.Slides allows you merge HTML docs in different ways. You get to merge HTML with all their texts, formatting,styles, etc.

Merge HTML to HTML in PHP

Using Aspose.Slides for PHP via Java , you can merge HTML files quickly with just a few lines of code

PHP code for merging HTML to HTML


<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

$pres = new Presentation();
try
{
    $pres->getSlides()->removeAt(0);
    
    $filename1 = 'file1.html';
    $f1 = fopen($filename1, 'r');
    if ($f1) {
        $contents1 = fread($f1, filesize($filename1));
        fclose($f1);
    }
    
    $pres->getSlides()->addFromHtml($contents1);
    
    $filename2 = 'file2.html';
    $f2 = fopen($filename2, 'r');
    if ($f2) {
        $contents2 = fread($f2, filesize($filename2));
        fclose($f2);
    }
    
    $pres->getSlides()->addFromHtml($contents2);

    $pres->save("merged-html.html", SaveFormat::Html5);
}
finally
{
    if ($pres != null) $pres->dispose();
}
?>

How to merge HTML in PHP

  1. Install Aspose.Slides for PHP via Java. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the HTML files you want to merge.

  5. Save the resulting HTML doc.

Merge PDF Files Online

How to Merge PDF in Python

Merge other files

You can also combine files in other formats to get a single file