PdfConverter Basic Conversion Guide
This guide shows how to convert Visio diagram files to PDF using the PdfConverter class in the Aspose.Diagram.LowCode namespace. PdfConverter accepts Visio input formats and always produces PDF output. For Visio-to-Visio format conversion, see the DiagramConverter Basic Conversion Guide
.
Prerequisites
Before using PdfConverter, 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 Visio-to-PDF Conversion
The simplest PdfConverter call takes an input Visio path and an output PDF path:
using Aspose.Diagram.LowCode;
PdfConverter.Process("source.vsdx", "output.pdf");Step 2: Conversion with Load and Save Options
Use LowCodeLoadOptions and LowCodePdfSaveOptions for explicit control over conversion parameters:
using Aspose.Diagram.LowCode;
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "source.vsdx";
var saveOptions = new LowCodePdfSaveOptions();
saveOptions.OutputFile = "output.pdf";
PdfConverter.Process(loadOptions, saveOptions);Step 3: PDF Compliance and Options
LowCodePdfSaveOptions exposes a PdfOptions property (type PdfSaveOptions) for PDF-specific settings, including compliance level:
using Aspose.Diagram.LowCode;
using Aspose.Diagram.Saving;
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "source.vsdx";
var saveOptions = new LowCodePdfSaveOptions();
saveOptions.OutputFile = "output.pdf";
var pdfOptions = new PdfSaveOptions();
pdfOptions.Compliance = PdfCompliance.PdfA1b;
saveOptions.PdfOptions = pdfOptions;
PdfConverter.Process(loadOptions, saveOptions);Step 4: Stream-Based Conversion
Use InputStream and OutputStream for in-memory conversion without writing temporary files to disk:
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 LowCodePdfSaveOptions();
saveOptions.OutputStream = outputStream;
PdfConverter.Process(loadOptions, saveOptions);
// outputStream now contains the PDF bytes
byte[] pdfBytes = outputStream.ToArray();Supported Formats
| Input Format | Output Format |
|---|---|
| VSDX | |
| VSD | |
| VDX | |
| VSDM | |
| VSSX | |
| VSTX |
Note: The output is always PDF. For Visio-to-Visio format conversion, use DiagramConverter.
Troubleshooting
| Problem | Likely Cause | Fix |
|---|---|---|
System.IO.FileNotFoundException | Input file path is incorrect | Verify the full path to the input file |
| Output file is not valid PDF | Input file is corrupted or unsupported | Open the input file in Visio to verify it is intact |
| Evaluation watermark in output | License not applied before calling Process() | Apply metered licensing via metered.SetMeteredKey() before any conversion |
NullReferenceException on PdfOptions | Accessing PdfOptions properties before assigning | Assign saveOptions.PdfOptions = new PdfSaveOptions() before setting properties |