Exporting Visio diagrams to PDF is one of the most common tasks in document workflows: sharing architecture diagrams, network maps, or flowcharts with stakeholders who don’t have Visio installed. Aspose.Diagram for .NET includes PdfConverter — a class in the Aspose.Diagram.LowCode namespace that handles this in a single method call.
In this article:
- Why PdfConverter?
- Installation
- Simple File Conversion
- Advanced Conversion with PDF Options
- Stream-Based Conversion
- Batch PDF Export
- ASP.NET Core Integration
- Tips for Production Use
Why PdfConverter?
PdfConverter is purpose-built for Visio-to-PDF conversion. Unlike the full Aspose.Diagram API, which exposes every diagram manipulation surface, PdfConverter has one job: take a Visio file, produce a PDF. That focus makes the API simpler and the code cleaner.
For Visio-to-Visio format conversion (VSDX ↔ VDX, VSD → VSDX, etc.), use
DiagramConverter— see Convert Visio Diagrams Between Formats.
Installation
Add Aspose.Diagram to your .NET project:
dotnet add package Aspose.Diagram
Or via Package Manager Console:
Install-Package Aspose.Diagram
Apply your metered license before any conversion:
using Aspose.Diagram;
Metered metered = new Metered();
metered.SetMeteredKey("publicKey", "privateKey");
For on-premise deployments, file-based licensing via License.SetLicense() is also supported.
Simple File Conversion
The simplest conversion takes an input path and an output path:
using Aspose.Diagram.LowCode;
PdfConverter.Process("architecture.vsdx", "architecture.pdf");
PdfConverter accepts VSDX, VSD, VDX, VSSX, VSTX, VSDM, and other Visio formats as input. The output is always PDF.
Advanced Conversion with PDF Options
For control over PDF output settings — including compliance level via PdfOptions — use LowCodeLoadOptions and LowCodePdfSaveOptions:
using Aspose.Diagram.LowCode;
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "flowchart.vsdx";
var saveOptions = new LowCodePdfSaveOptions();
saveOptions.OutputFile = "flowchart.pdf";
PdfConverter.Process(loadOptions, saveOptions);
LowCodePdfSaveOptions provides PDF-specific configuration not available in the simple file-path overload. Use it whenever you need to control PDF compliance level or other PDF output settings via the PdfOptions property.
Stream-Based Conversion
For in-memory processing — web APIs, pipeline stages, or avoiding temporary disk writes:
using System.IO;
using Aspose.Diagram.LowCode;
var loadOptions = new LowCodeLoadOptions();
using (var inputStream = File.OpenRead("network-diagram.vsdx"))
{
loadOptions.InputStream = inputStream;
var saveOptions = new LowCodePdfSaveOptions();
using (var outputStream = new MemoryStream())
{
saveOptions.OutputStream = outputStream;
PdfConverter.Process(loadOptions, saveOptions);
// Return from web API, store in cloud, etc.
byte[] pdfBytes = outputStream.ToArray();
}
}
Batch PDF Export
Export all Visio files in a directory to PDF:
using System.IO;
using Aspose.Diagram.LowCode;
string inputDir = "diagrams/input";
string outputDir = "diagrams/output";
Directory.CreateDirectory(outputDir);
foreach (var file in Directory.GetFiles(inputDir, "*.vsdx"))
{
string output = Path.Combine(outputDir, Path.GetFileNameWithoutExtension(file) + ".pdf");
PdfConverter.Process(file, output);
Console.WriteLine($"Exported: {Path.GetFileName(file)} → {Path.GetFileName(output)}");
}
ASP.NET Core Integration
Expose Visio-to-PDF conversion as an HTTP endpoint:
using System.IO;
using Aspose.Diagram.LowCode;
[HttpPost("export-pdf")]
public IActionResult ExportToPdf(IFormFile visioFile)
{
string tempInput = Path.GetTempFileName() + ".vsdx";
try
{
using (var stream = new FileStream(tempInput, FileMode.Create))
visioFile.CopyTo(stream);
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = tempInput;
var saveOptions = new LowCodePdfSaveOptions();
var ms = new MemoryStream();
saveOptions.OutputStream = ms;
PdfConverter.Process(loadOptions, saveOptions);
return File(ms.ToArray(), "application/pdf",
Path.ChangeExtension(visioFile.FileName, ".pdf"));
}
finally
{
File.Delete(tempInput);
}
}
Tips for Production Use
- Apply licensing at startup. Call
SetLicenseorSetMeteredKeybefore anyProcess()call to avoid evaluation watermarks in the output PDF. - Use
LowCodePdfSaveOptionsfor compliance. If your output must meet PDF/A or PDF/X standards, configure it through the options object. - Stream-based for web APIs. Avoid writing temporary files by routing through
MemoryStream— cleaner, faster, and no temp file cleanup required. - Wrap batch jobs in try-catch per file. One corrupt input diagram should not abort the entire batch.
- Error handling. Catch
ExceptionaroundProcess()calls; Aspose.Diagram throws descriptive exceptions for unsupported formats and licensing issues.
What’s Next?
- PdfConverter Developer Guide — detailed API documentation with all options and error patterns
- PdfConverter KB Articles — step-by-step how-to guides
- Aspose.Diagram Products Page — overview, FAQs, and integration steps
- Convert Visio Between Formats — use
DiagramConverterfor Visio-to-Visio conversion