Diagram Converter Developer Guide

The DiagramConverter class in Aspose.Diagram.LowCode provides a streamlined API for Visio diagram conversion and processing.

Installation and Setup

Install via NuGet:

dotnet add package Aspose.Diagram

Apply metered licensing before use:

using Aspose.Diagram;

Metered metered = new Metered();
metered.SetMeteredKey("publicKey", "privateKey");

Features and Functionalities

File Format Support

  • Input: VSDX, VSD, VDX, VSSX, VSTX, VSX, and more
  • Output: All supported Visio formats (VSDX, VSD, VDX, etc.) — for PDF output, use PdfConverter

Simple Conversion

Convert between Visio formats with a single line:

using Aspose.Diagram.LowCode;

// VSDX to VDX
DiagramConverter.Process("source.vsdx", "output.vdx");

// VSD to VSDX (legacy to modern format)
DiagramConverter.Process("legacy.vsd", "modernized.vsdx");

Advanced Conversion with Options

For fine-grained control:

using Aspose.Diagram.LowCode;

var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "source.vsdx";

var saveOptions = new LowCodeSaveOptions();
saveOptions.OutputFile = "output.vdx";

DiagramConverter.Process(loadOptions, saveOptions);

Stream-Based Processing

For in-memory or web application scenarios:

using System.IO;
using Aspose.Diagram.LowCode;

var loadOptions = new LowCodeLoadOptions();
using (var inputStream = File.OpenRead("source.vsdx"))
{
    loadOptions.InputStream = inputStream;

    var saveOptions = new LowCodeSaveOptions();
    using (var outputStream = new MemoryStream())
    {
        saveOptions.OutputStream = outputStream;
        DiagramConverter.Process(loadOptions, saveOptions);
        // Use outputStream.ToArray() for the converted bytes
    }
}

Usage Examples

Basic File Conversion

using Aspose.Diagram.LowCode;

DiagramConverter.Process("template.vsdx", "result.vdx");

Batch Processing

using System.IO;
using Aspose.Diagram.LowCode;

string inputDir = "input";
string outputDir = "output";
Directory.CreateDirectory(outputDir);

foreach (var file in Directory.GetFiles(inputDir, "*.vsdx"))
{
    string output = Path.Combine(outputDir, Path.GetFileNameWithoutExtension(file) + ".vdx");
    DiagramConverter.Process(file, output);
}

Tips and Best Practices

  • Licensing: Always apply your license before calling Process() to avoid evaluation watermarks.
  • Error Handling: Wrap conversions in try-catch blocks for robust production code.
  • Options reuse: Create LowCodeLoadOptions/LowCodeSaveOptions once and reuse in loops.
  • Large files: Use stream-based processing to minimize memory allocation.

Common Issues and Resolutions

IssueResolution
File not foundVerify path is correct; use absolute paths in production
Unsupported formatCheck supported formats list; ensure file extension matches content
Evaluation watermarkApply a valid license before processing
Memory errors on large filesSwitch to stream-based processing

API Reference

See Also