Convert SVG to DOCX in C#

To convert SVG to DOCX in C#, load the SVG document or prepare SVG content, create DocSaveOptions, and call Converter.ConvertSVG() with the source, options, and output path.

DOCX is useful when SVG content must become part of an editable Word document for review, reporting, or office workflows. Aspose.HTML for .NET renders SVG content to DOCX through ConvertSVG() and DocSaveOptions.

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 DOCX with One Line of C#

The static Converter class provides a compact way to render SVG content to DOCX. The example below converts a local SVG file to DOCX with default DocSaveOptions.

1// Convert SVG to DOCX using C#
2
3// Invoke the ConvertSVG() method to convert SVG to DOCX
4Converter.ConvertSVG(Path.Combine(DataDir, "shapes.svg"), new DocSaveOptions(), Path.Combine(OutputDir, "convert-with-single-line.docx"));

Convert SVG to DOCX in C#

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

The workflow is:

  1. Prepare the SVG content and base URI.
  2. Create a DocSaveOptions instance.
  3. Call Converter.ConvertSVG(content, baseUri, options, outputPath).
  4. Save the generated DOCX file to the target output path.
 1// Convert SVG to DOCX 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='none' stroke='red' stroke-width='10' />" +
 6              "</svg>";
 7
 8// Prepare a path for converted file saving
 9string savePath = Path.Combine(OutputDir, "circle.docx");
10
11// Initialize DocSaveOptions
12DocSaveOptions options = new DocSaveOptions();
13
14// Convert SVG to DOCX
15Converter.ConvertSVG(code, ".", options, savePath);

Customize SVG to DOCX with DocSaveOptions

Use DocSaveOptions when the generated DOCX file needs custom rendering settings.

To customize SVG to DOCX conversion:

  1. Load the SVG file as an SVGDocument.
  2. Create DocSaveOptions.
  3. Configure only the settings required by the output, such as PageSetup, FontEmbeddingRule, DocumentFormat, CSS processing, or resolution.
  4. Pass the document, options, and output path to Converter.ConvertSVG().
OptionUse it to control
FontEmbeddingRuleFont embedding in the output document. Available values are Full and None; the default value is None.
CssCSS processing behavior through CssOptions.
DocumentFormatThe output document format. The default value is DOCX.
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.
 1// Convert SVG to DOCX in C# with custom page settings
 2
 3// Prepare a path to a source SVG file
 4string documentPath = Path.Combine(DataDir, "shapes.svg");
 5
 6// Prepare a path for converted file saving
 7string savePath = Path.Combine(OutputDir, "shapes-options.docx");
 8
 9// Initialize an SVG document from the file
10using SVGDocument document = new SVGDocument(documentPath);
11
12// Initialize DocSaveOptions. Set up the page-size and margins
13DocSaveOptions options = new DocSaveOptions();
14options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(500, 500), new Margin(30, 10, 10, 10));
15
16// Convert SVG to DOCX
17Converter.ConvertSVG(document, options, savePath);

Related DOCX Workflows

Related SVG Conversion Guides

Other Platforms

Try Online SVG to DOCX Conversion

                
            

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

SVG to DOCX Converter

FAQ

Can I convert SVG to DOCX for free?

You can evaluate Aspose.HTML for .NET before purchasing a license, but converted documents created in evaluation mode contain watermarks and are limited to four pages. For unrestricted testing, request a free 30-day Temporary License. For occasional manual conversions, use the free online SVG to DOCX Converter.

See Licensing Aspose.HTML for .NET for evaluation limitations and license setup.

Can I edit the original SVG elements in the converted DOCX?

The conversion renders SVG content into the DOCX layout; it is not an SVG-to-Word-shapes editor. Text and graphics may not become independently editable Word objects. Keep the source SVG when you need to revise paths, filters, or other vector elements.