Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
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.
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"));Use this workflow when SVG content is created in code and then saved as a DOCX file.
The workflow is:
DocSaveOptions instance.Converter.ConvertSVG(content, baseUri, options, outputPath). 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);Use DocSaveOptions when the generated DOCX file needs custom rendering settings.
To customize SVG to DOCX conversion:
SVGDocument.DocSaveOptions.PageSetup, FontEmbeddingRule, DocumentFormat, CSS processing, or resolution.Converter.ConvertSVG().| Option | Use it to control |
|---|---|
FontEmbeddingRule | Font embedding in the output document. Available values are Full and None; the default value is None. |
Css | CSS processing behavior through CssOptions. |
DocumentFormat | The output document format. The default value is DOCX. |
PageSetup | Page size, margins, and page layout settings. |
HorizontalResolution and VerticalResolution | Output 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);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.
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.
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.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.