Convert HTML to Image in Java
Convert HTML files to image files using Aspose.Slides for Java without Microsoft PowerPoint.
Convert HTML to Image in Java
Aspose.Slides for Java
is a presentation processing API that can import HTML content and render the resulting slides as image files.
You can load an HTML file into a Presentation, render each ISlide as an IImage, and save the output in an image format such as PNG.
Convert HTML to Image using Java
To convert HTML to image files, create a Presentation from the source file and render its slides.
Java code for converting HTML into Image
Presentation presentation = new Presentation();
try {
presentation.getSlides().removeAt(0);
try (FileInputStream htmlStream = new FileInputStream("page.html")) {
presentation.getSlides().addFromHtml(htmlStream);
}
for (int slideIndex = 0; slideIndex < presentation.getSlides().size(); slideIndex++) {
ISlide slide = presentation.getSlides().get_Item(slideIndex);
IImage slideImage = slide.getImage(1f, 1f);
try {
slideImage.save("slide_" + (slideIndex + 1) + ".png", ImageFormat.Png);
} finally {
slideImage.dispose();
}
}
} finally {
presentation.dispose();
}
How to convert HTML to Image using Aspose.Slides for Java API
These are the steps to convert HTML to Image in Java.
Install Aspose.Slides for Java .
Add a library reference (import the library) to your Java project.
Load the source
HTMLfile into aPresentation.Render each
ISlideas anIImageand save it as an image file.
Free Online Converter
Convert presentations and slides online.
Convert HTML To Other Supported Formats
You can also convert HTML and save it to other file formats.