Convert HTML to JPG in Java
Convert HTML files to JPG images using Aspose.Slides for Java without Microsoft PowerPoint.
Convert HTML to JPG in Java
Aspose.Slides for Java
is a presentation processing API that can import HTML content and render the resulting slides as JPG images.
You can load an HTML file into a Presentation, render each ISlide as an IImage, and save the output with ImageFormat.Jpeg.
Convert HTML to JPG using Java
To convert HTML to JPG, create a Presentation from the source file and render its slides.
Java code for converting HTML into JPG
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) + ".jpg", ImageFormat.Jpeg);
} finally {
slideImage.dispose();
}
}
} finally {
presentation.dispose();
}
How to convert HTML to JPG using Aspose.Slides for Java API
These are the steps to convert HTML to JPG 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 aJPGfile.
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.