DiagramConverter Basic Conversion Guide
This guide shows how to convert Visio diagram files between formats using the DiagramConverter class in the Aspose.Diagram.LowCode namespace. DiagramConverter handles Visio-to-Visio format conversions. For Visio-to-PDF conversion, see the PdfConverter Basic Conversion Guide
.
Prerequisites
Before using DiagramConverter, ensure you have:
- Aspose.Diagram for .NET — Install via NuGet:
dotnet add package Aspose.Diagram - License — Apply your metered license before any conversions:
using Aspose.Diagram; Metered metered = new Metered(); metered.SetMeteredKey("publicKey", "privateKey"); - Input file — A Visio file in any supported input format (see Supported Formats below).
Step 1: Simple File Conversion
The simplest DiagramConverter call takes two string arguments: input path and output path. The output format is determined automatically from the destination file extension.
using Aspose.Diagram.LowCode;
// Convert VSDX to VDX format
DiagramConverter.Process("source.vsdx", "output.vdx");
// Convert legacy VSD to modern VSDX
DiagramConverter.Process("legacy.vsd", "modernized.vsdx");Step 2: Conversion with Load and Save Options
Use LowCodeLoadOptions and LowCodeSaveOptions when you need explicit control over input and output paths, or when preparing for stream-based processing:
using Aspose.Diagram.LowCode;
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "source.vsdx";
var saveOptions = new LowCodeSaveOptions();
saveOptions.OutputFile = "output.vdx";
DiagramConverter.Process(loadOptions, saveOptions);Step 3: Stream-Based Conversion
Use InputStream and OutputStream to convert without writing files to disk. This is the recommended pattern for web applications and batch pipelines:
using System.IO;
using Aspose.Diagram.LowCode;
using var inputStream = File.OpenRead("source.vsdx");
using var outputStream = new MemoryStream();
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputStream = inputStream;
var saveOptions = new LowCodeSaveOptions();
saveOptions.OutputStream = outputStream;
DiagramConverter.Process(loadOptions, saveOptions);
// outputStream now contains the converted diagram bytes
byte[] result = outputStream.ToArray();Step 4: Batch Conversion
To convert multiple files, call DiagramConverter.Process() in a loop:
using System.IO;
using Aspose.Diagram.LowCode;
string inputDir = "diagrams/input/";
string outputDir = "diagrams/output/";
Directory.CreateDirectory(outputDir);
foreach (string inputFile in Directory.GetFiles(inputDir, "*.vsdx"))
{
string outputFile = Path.Combine(outputDir, Path.GetFileNameWithoutExtension(inputFile) + ".vdx");
DiagramConverter.Process(inputFile, outputFile);
}Supported Formats
| Input Format | Output Format |
|---|---|
| VSDX | VSDX, VSD, VDX, VSSX, VSTX, VSX, VSDM |
| VSD | VSDX, VSD, VDX, and others |
| VDX | VSDX, VSD, VDX, and others |
| VSSX | VSSX, VSDX, and others |
| VSTX | VSTX, VSDX, and others |
| VSDM | VSDM, VSDX, and others |
Note: The output format is always determined by the destination file extension. For PDF output, use PdfConverter — DiagramConverter converts between Visio formats only.
Troubleshooting
| Problem | Likely Cause | Fix |
|---|---|---|
System.IO.FileNotFoundException | Input file path is incorrect | Verify the full path to the input file |
| Output format not recognized | Destination extension is not a supported Visio format | Use a supported extension (.vsdx, .vdx, .vsd, etc.) |
| Evaluation watermark in output | License not applied before calling Process() | Apply metered licensing via metered.SetMeteredKey() before any conversion |
InvalidOperationException on InputStream | InputStream is null or already closed | Ensure the stream is open and non-null before passing to LowCodeLoadOptions |