Merge HTML in Java

Use Aspose.Slides for Java to merge HTML files in Java applications.

Merge HTML to HTML using Aspose.Slides

Aspose.Slides for Java is a Java API for creating, editing, converting, and merging presentation content. You can place HTML files into a Presentation and save the merged content as an HTML file.

Merge HTML to HTML in Java

Using Aspose.Slides for Java , you can merge HTML files and create an HTML result with a few lines of Java code.

Java code for merging HTML to HTML

Presentation presentation = new Presentation();
try {
    presentation.getSlides().removeAt(0);

    FileInputStream firstHtmlStream = new FileInputStream("file1.html");
    try {
        presentation.getSlides().addFromHtml(firstHtmlStream);
    } finally {
        firstHtmlStream.close();
    }

    FileInputStream secondHtmlStream = new FileInputStream("file2.html");
    try {
        presentation.getSlides().addFromHtml(secondHtmlStream);
    } finally {
        secondHtmlStream.close();
    }

    presentation.save("merged.html", SaveFormat.Html);
} finally {
    presentation.dispose();
}

How to merge HTML files in Java

  1. Install Aspose.Slides for Java .

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

  3. Create a Presentation instance.

  4. Import the source HTML files with addFromHtml.

  5. Save the merged content with SaveFormat.Html.

Merge Files Online

Merge presentations and slides online.

Merge other files

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