Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
To convert HTML to TIFF in C#, use
Converter.ConvertHTML() with an HTML source,
ImageSaveOptions, ImageFormat.Tiff, and an output path. ImageSaveOptions lets you control image format, TIFF compression, page setup, background color, resolution, CSS media type, and rendering quality.
This guide shows the core HTML to TIFF workflows for C# applications: file-based conversion and custom image rendering options. Before running the examples, install and configure Aspose.HTML for .NET in your project. The complete C# example project is available in the Aspose.HTML for .NET GitHub repository.
TIFF is a raster image format commonly used for archiving, publishing, scanning, and workflows that need configurable image compression. Use HTML to TIFF conversion when your application needs to render a web page, generated HTML, or template output into TIFF image output.
A typical file-based conversion uses an
HTMLDocument instance, an ImageSaveOptions object configured with ImageFormat.Tiff, and Converter.ConvertHTML(). By default, ImageSaveOptions uses PNG as the output image format, so set the format explicitly for TIFF output.
The workflow is:
HTMLDocument constructor.ImageSaveOptions instance with ImageFormat.Tiff.Converter.ConvertHTML(document, options, savePath) to render the HTML document as a TIFF image.The following C# code converts an HTML document to TIFF.
1// Convert HTML to TIFF using C#
2
3// Prepare a path to a source HTML file
4string documentPath = Path.Combine(DataDir, "nature.html");
5
6// Prepare a path for converted file saving
7string savePath = Path.Combine(OutputDir, "nature-output.tiff");
8
9// Initialize an HTML document from the file
10using HTMLDocument document = new HTMLDocument(documentPath);
11
12// Create an instance of the ImageSaveOptions class
13ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff);
14
15// Convert HTML to TIFF
16Converter.ConvertHTML(document, options, savePath);Use TIFF output when the rendered HTML page is intended for archiving, printing, scanning, document imaging, or systems that expect TIFF files. TIFF is the image format in this group where Compression is directly relevant. For web previews,
HTML to PNG or
HTML to JPG is usually easier to handle.
For TIFF output, create ImageSaveOptions(ImageFormat.Tiff) explicitly because the default ImageSaveOptions.Format value is PNG. The Compression property controls TIFF compression; the default value is LZW. You can also tune page setup, background color, resolution, antialiasing, and text rendering.
Use
ImageSaveOptions when the output image needs custom rendering settings. The same options class is used for PNG, JPG, BMP, GIF, and TIFF output; for TIFF, set Format to ImageFormat.Tiff.
| Option | Use it to control |
|---|---|
Format | Output image format, such as PNG, JPG, BMP, GIF, or TIFF. The default value is ImageFormat.Png. |
Compression | TIFF compression used for the output image. The default value is LZW. |
PageSetup | Output page size and margins used during rendering. |
BackgroundColor | Background fill color. The default value is transparent. |
HorizontalResolution | Horizontal resolution for output images in pixels per inch. The default value is 300 dpi. |
VerticalResolution | Vertical resolution for output images in pixels per inch. The default value is 300 dpi. |
UseAntialiasing | Rendering quality for shapes, text, and images. Antialiasing is enabled by default. |
CSS | CSS media type and related CSS processing options. |
Text | Text rendering options for image output. |
The following example converts HTML to TIFF using custom save options such as TIFF compression, background color, resolution, and rendering quality.
1// Convert HTML to TIFF with custom settings using C#
2
3string documentPath = Path.Combine(DataDir, "nature.html");
4string savePath = Path.Combine(OutputDir, "nature-output-options.tiff");
5
6
7// Initialize an HTML Document from the html file
8using HTMLDocument document = new HTMLDocument(documentPath);
9
10// Initialize ImageSaveOptions
11ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff)
12{
13 Compression = Compression.None,
14 BackgroundColor = System.Drawing.Color.Bisque,
15 HorizontalResolution = 150,
16 VerticalResolution = 150,
17 UseAntialiasing = true,
18};
19
20// Convert HTML to TIFF
21Converter.ConvertHTML(document, options, savePath);In this example, ImageSaveOptions is passed to Converter.ConvertHTML() together with the loaded HTML document and output path. The sample configures TIFF compression, background color, horizontal and vertical resolution, and antialiasing behavior.
Use UseAntialiasing = true when visual smoothness is more important than rendering speed. Use UseAntialiasing = false for simpler, performance-oriented rendering where sharper edges or faster processing are acceptable.
PdfSaveOptions.DocSaveOptions.Use the online HTML to TIFF Converter for quick manual conversion. Use Aspose.HTML for .NET when HTML to TIFF rendering must run inside a C# application, service, reporting tool, or image-archiving workflow.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.