DiagramConverter Basic Conversion Guide

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:

  1. Aspose.Diagram for .NET — Install via NuGet:
    dotnet add package Aspose.Diagram
  2. License — Apply your metered license before any conversions:
    using Aspose.Diagram;
    
    Metered metered = new Metered();
    metered.SetMeteredKey("publicKey", "privateKey");
  3. 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 FormatOutput Format
VSDXVSDX, VSD, VDX, VSSX, VSTX, VSX, VSDM
VSDVSDX, VSD, VDX, and others
VDXVSDX, VSD, VDX, and others
VSSXVSSX, VSDX, and others
VSTXVSTX, VSDX, and others
VSDMVSDM, VSDX, and others

Note: The output format is always determined by the destination file extension. For PDF output, use PdfConverterDiagramConverter converts between Visio formats only.

Troubleshooting

ProblemLikely CauseFix
System.IO.FileNotFoundExceptionInput file path is incorrectVerify the full path to the input file
Output format not recognizedDestination extension is not a supported Visio formatUse a supported extension (.vsdx, .vdx, .vsd, etc.)
Evaluation watermark in outputLicense not applied before calling Process()Apply metered licensing via metered.SetMeteredKey() before any conversion
InvalidOperationException on InputStreamInputStream is null or already closedEnsure the stream is open and non-null before passing to LowCodeLoadOptions

See Also