Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
To convert HTML to BMP in C#, use
Converter.ConvertHTML() with an HTML source,
ImageSaveOptions, ImageFormat.Bmp, and an output path. ImageSaveOptions lets you control page setup, background color, resolution, CSS media type, and rendering quality.
This guide shows the core HTML to BMP 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.
BMP is an uncompressed bitmap image format used when an application needs simple raster output and broad compatibility with image-processing tools. Use HTML to BMP conversion when file size is less important than preserving rendered pixel data in a straightforward bitmap format.
A typical file-based conversion uses an
HTMLDocument instance, an ImageSaveOptions object configured with ImageFormat.Bmp, and Converter.ConvertHTML(). By default, ImageSaveOptions uses PNG as the output image format, so set the format explicitly for BMP output.
The workflow is:
HTMLDocument constructor.ImageSaveOptions instance with ImageFormat.Bmp.Converter.ConvertHTML(document, options, savePath) to render the HTML document as a BMP image.The following C# code converts the sample file bmp.html to BMP.
1// Convert HTML to BMP using C#
2
3// Prepare a path to a source HTML file
4string documentPath = Path.Combine(DataDir, "bmp.html");
5
6// Prepare a path to save the converted file
7string savePath = Path.Combine(OutputDir, "bmp-output.bmp");
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.Bmp);
14
15// Convert HTML to BMP
16Converter.ConvertHTML(document, options, savePath);Use BMP output when a Windows-oriented tool, legacy imaging workflow, or downstream system expects bitmap files. BMP can be useful for simple raster handoff and compatibility testing, but it is usually not the best format for web delivery because files can be large. For web previews, HTML to JPG or HTML to PNG is usually more practical.
For BMP output, create ImageSaveOptions(ImageFormat.Bmp) explicitly because the default ImageSaveOptions.Format value is PNG. You can then 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 BMP, set Format to ImageFormat.Bmp.
| Option | Use it to control |
|---|---|
Format | Output image format, such as PNG, JPG, BMP, GIF, or TIFF. The default value is ImageFormat.Png. |
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 BMP using custom save options such as background color, resolution, and rendering quality.
1// Convert HTML to BMP in C# with custom background, resolution, and antialiasing settings
2
3// Prepare a path to a source HTML file
4string documentPath = Path.Combine(DataDir, "bmp.html");
5
6// Prepare a path for converted file saving
7string savePath = Path.Combine(OutputDir, "bmp-output-options.bmp");
8
9// Initialize an HTML Document from the html file
10using HTMLDocument document = new HTMLDocument(documentPath);
11
12// Initialize ImageSaveOptions
13ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Bmp)
14{
15 UseAntialiasing = false,
16 HorizontalResolution = 350,
17 VerticalResolution = 350,
18 BackgroundColor = System.Drawing.Color.Beige
19};
20
21// Convert HTML to BMP
22Converter.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 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.
The custom settings example produces a BMP image similar to the following output:

PdfSaveOptions.DocSaveOptions.Use the online HTML to BMP Converter for quick manual conversion. Use Aspose.HTML for .NET when HTML to BMP rendering must run inside a C# application, service, reporting tool, or image-generation workflow.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.