PdfConverter Basic Conversion Guide

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:

  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 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 FormatOutput Format
VSDXPDF
VSDPDF
VDXPDF
VSDMPDF
VSSXPDF
VSTXPDF

Note: The output is always PDF. For Visio-to-Visio format conversion, use DiagramConverter.

Troubleshooting

ProblemLikely CauseFix
System.IO.FileNotFoundExceptionInput file path is incorrectVerify the full path to the input file
Output file is not valid PDFInput file is corrupted or unsupportedOpen the input file in Visio to verify it is intact
Evaluation watermark in outputLicense not applied before calling Process()Apply metered licensing via metered.SetMeteredKey() before any conversion
NullReferenceException on PdfOptionsAccessing PdfOptions properties before assigningAssign saveOptions.PdfOptions = new PdfSaveOptions() before setting properties

See Also