ImageSaveOptions Class

ImageSaveOptions class

Specific options data class. It provides properties to manage image result resolution, smooting quality, format as well as page settings and etc. More info you can obtain in documentation article.

public class ImageSaveOptions : ImageRenderingOptions

Constructors

NameDescription
ImageSaveOptions()Initializes a new instance of the ImageSaveOptions class; Png will be used as default image format.
ImageSaveOptions(ImageFormat)Image format ImageFormat based on initialization

Properties

NameDescription
BackgroundColor { get; set; }Gets or sets Color which will fill background of every page. Default value is Transparent.
Compression { get; set; }Sets or gets Tagged Image File Format (TIFF) Compression. By default this property is LZW.
Css { get; }Gets a CssOptions object which is used for configuration of css properties processing.
Format { get; set; }Sets or gets ImageFormat. By default this property is Png.
override HorizontalResolution { get; set; }Sets or gets horizontal resolution for output and internal (which are used during filters processing) images, in pixels per inch. By default this property is 300 dpi.
PageSetup { get; }Gets a page setup object is used for configuration output page-set.
SmoothingMode { get; set; }Gets or sets the rendering quality for this Graphics.
Text { get; }Gets a TextOptions object which is used for configuration of text rendering.
override VerticalResolution { get; set; }Sets or gets vertical resolution for output and internal (which are used during filters processing) images, in pixels per inch. By default this property is 300 dpi.

Remarks

You can download the complete examples and data files from GitHub.

Examples

using Aspose.Html;
using Aspose.Html.Converters;
using Aspose.Html.Drawing;
using Aspose.Html.Rendering.Image;
using Aspose.Html.Saving;
...
      // Prepare a path to a source HTML file
      string documentPath = Path.Combine(DataDir, "nature.html");

      // Prepare a path for converted file saving 
      string savePath = Path.Combine(OutputDir, "nature-output-options.png");

      // Initialize an HTML document from the file
      using var document = new HTMLDocument(documentPath);

      // Initialize ImageSaveOptions       
      var options = new ImageSaveOptions()
      {
        SmoothingMode = SmoothingMode.Default,
        HorizontalResolution = 100,
        VerticalResolution = 100,
        BackgroundColor = Color.Beige
      };

      // Convert HTML to PNG
      Converter.ConvertHTML(document, options, savePath);

See Also