Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 18, 2025 23:00
HTML to TIFF
public static void main(String[] args)
{
// Define path for the working files.
String dir = "/files/";
try {
// Call the HTMLDocument method to load the source HTML file.
com.aspose.html.HTMLDocument htmlDocument = new com.aspose.html.HTMLDocument(dir+"sample.html");
// Initialize an object of the ImageSaveOptions class with the TIFF image format.
com.aspose.html.saving.ImageSaveOptions options = new com.aspose.html.saving.ImageSaveOptions(com.aspose.html.rendering.image.ImageFormat.Tiff);
// The setBackgroundColor method will make the background color of the TIFF image white.
options.setBackgroundColor(Color.getWhite());
// Convert HTML to TIFF by calling the convertHTML method.
com.aspose.html.converters.Converter.convertHTML(htmlDocument, options, dir+"HTMLtoTIFF_Output.tiff");
System.err.println("HTML to TIFF Conversion completed.");
} catch (Exception e) {
// TODO: handle exception
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment