Merge HTML to Image in Java
Use Aspose.Slides for Java to merge HTML files in Java applications.
Merge HTML to PNG in Java
Using
Aspose.Slides for Java
, you can merge HTML files and create a PNG result with a few lines of Java code.
Java code for merging HTML to PNG
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();
}
for (ISlide slide : presentation.getSlides()) {
IImage slideImage = slide.getImage(1f, 1f);
try {
slideImage.save("slide_" + slide.getSlideNumber() + ".png", ImageFormat.Png);
} finally {
slideImage.dispose();
}
}
} finally {
presentation.dispose();
}Merge HTML to PNG 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 render the merged slides as PNG images.
How to merge HTML files in Java
- Install Aspose.Slides for Java.
- Add the library as a reference in your project.
- Create a
Presentationinstance. - Import the source
HTMLfiles withaddFromHtml. - Render each slide with
getImageand save it withImageFormat.Png.
Built with Aspose.Slides
Merge HTML to Image Online
The free Aspose.Slides Merger app is built with Aspose.Slides for 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 Image file.
- Download the merged result as one file.
Merge other files
You can also combine files in other formats to get a single file.