Convert SVG to TIFF in C#

To convert SVG to TIFF in C#, load the SVG document or prepare SVG content, create ImageSaveOptions with ImageFormat.Tiff, configure TIFF-specific options such as Compression when needed, and call Converter.ConvertSVG() with the source, options, and output path.

TIFF is commonly used in archiving, printing, scanning, and document imaging workflows. SVG to TIFF conversion is useful when vector graphics must be rendered into a raster format that supports TIFF compression and document-image style storage.

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.

Convert SVG to TIFF with One Line of C#

The static Converter class provides a compact way to render SVG content to TIFF. The example below converts a local SVG file to TIFF.

1// Convert SVG to TIFF using C#
2
3// Invoke the ConvertSVG() method for SVG to TIFF conversion
4Converter.ConvertSVG(Path.Combine(DataDir, "shapes.svg"), new ImageSaveOptions(ImageFormat.Tiff), Path.Combine(OutputDir, "convert-with-single-line.tiff"));

Convert SVG to TIFF in C#

Use this workflow when SVG content is created in code and then saved as a TIFF file.

The workflow is:

  1. Prepare the SVG content and base URI.
  2. Create ImageSaveOptions with ImageFormat.Tiff. The default Format value is PNG, so the format must be set for TIFF output.
  3. Call Converter.ConvertSVG(content, baseUri, options, outputPath).
  4. Save the generated TIFF file to the target output path.
 1// Convert SVG to TIFF in C#
 2
 3// Prepare SVG code
 4string code = "<svg xmlns='http://www.w3.org/2000/svg'>" +
 5              "<circle cx ='100' cy ='100' r ='50' fill='pink' stroke='red' stroke-width='10' />" +
 6              "</svg>";
 7
 8// Prepare a path for converted file saving
 9string savePath = Path.Combine(OutputDir, "circle.tiff");
10
11// Create an instance of the ImageSaveOptions class
12ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff);
13
14// Convert SVG to TIFF
15Converter.ConvertSVG(code, ".", options, savePath);

TIFF Compression and Output Notes

Use TIFF output when the rendered SVG 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, SVG to PNG or SVG to JPG is usually easier to handle.

Customize SVG to TIFF with ImageSaveOptions

Use ImageSaveOptions when the generated TIFF needs custom rendering settings.

To customize SVG to TIFF conversion:

  1. Load the SVG file as an SVGDocument.
  2. Create ImageSaveOptions with ImageFormat.Tiff.
  3. Configure only the settings required by the output, such as Compression, PageSetup, BackgroundColor, resolution, or UseAntialiasing.
  4. Pass the document, options, and output path to Converter.ConvertSVG().
OptionUse it to control
CompressionTIFF compression. Available values include LZW, CCITT3, CCITT4, Rle, and None; the default value is LZW.
FormatThe output image format. The default value is PNG; use ImageFormat.Tiff for TIFF output.
BackgroundColorThe color used to fill the image background. The default value is transparent.
PageSetupPage size, margins, and page layout settings.
HorizontalResolution and VerticalResolutionOutput resolution values used by the rendering process. The default value is 300 dpi for each property.
UseAntialiasingImage rendering quality. Antialiasing is enabled by default.
TextText rendering configuration through TextOptions.
 1// Convert SVG to TIFF in C# with custom background, resolution, and compression settings
 2
 3// Prepare a path to a source SVG file
 4string documentPath = Path.Combine(DataDir, "gradient.svg");
 5
 6// Prepare a path for converted file saving
 7string savePath = Path.Combine(OutputDir, "gradient-options.tiff");
 8
 9// Initialize an SVG document from the file
10using SVGDocument document = new SVGDocument(documentPath);
11
12// Initialize ImageSaveOptions. Set up the compression, resolutions, and change the background color to AliceBlue
13ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff)
14{
15    Compression = Compression.None,
16    HorizontalResolution = 200,
17    VerticalResolution = 200,
18    BackgroundColor = System.Drawing.Color.AliceBlue
19};
20
21// Convert SVG to TIFF
22Converter.ConvertSVG(document, options, savePath);

The image below illustrates a TIFF rendering result with custom image save options.

Gradient SVG rendered as TIFF

Related SVG Conversion Guides

Other Platforms

Try Online SVG to TIFF Conversion

                
            

Use the online SVG to TIFF Converter for quick manual conversion. Use Aspose.HTML for .NET when SVG to TIFF conversion must run inside a C# application, service, or document pipeline.

SVG to TIFF Converter