Skip to content

Instantly share code, notes, and snippets.

How to Convert HTML to Image in Java. For more information, please follow link: https://kb.groupdocs.com/conversion/java/how-to-convert-html-to-image-in-java/
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.licensing.License;
import com.groupdocs.conversion.options.convert.ImageConvertOptions;
public class ConvertHtmlToImageInJava {
public static void main(String[] args) { // Main function to convert HTML to Image in Java
// Remove the watermark in output Image document by adding license
License lic = new License();
lic.setLicense("GroupDocs.Conversion.lic");
// Load the source HTML file for conversion to Image
Converter converter = new Converter("sample.html");
// Set the convert options for PNG format
ImageConvertOptions options = new ImageConvertOptions();
// Convert and save the HTML in PNG format
converter.convert("converted.png", options);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment