Pdf Converter Developer Guide
The PdfConverter class in Aspose.Diagram.LowCode provides a streamlined API for Visio-to-PDF conversion.
Installation and Setup
Install via NuGet:
dotnet add package Aspose.DiagramApply 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: PDF only — for Visio-to-Visio conversions, use
DiagramConverter
Simple Conversion
Convert a Visio file to PDF with a single line:
using Aspose.Diagram.LowCode;
PdfConverter.Process("source.vsdx", "output.pdf");Advanced Conversion with Options
For fine-grained control:
using Aspose.Diagram.LowCode;
var loadOptions = new LowCodeLoadOptions();
loadOptions.InputFile = "source.vsdx";
var saveOptions = new LowCodePdfSaveOptions();
saveOptions.OutputFile = "output.pdf";
PdfConverter.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 LowCodePdfSaveOptions();
using (var outputStream = new MemoryStream())
{
saveOptions.OutputStream = outputStream;
PdfConverter.Process(loadOptions, saveOptions);
// Use outputStream.ToArray() for the converted bytes
}
}Usage Examples
Basic File Conversion
using Aspose.Diagram.LowCode;
PdfConverter.Process("template.vsdx", "result.pdf");PDF/A Compliance
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 pdfOpts = new PdfSaveOptions();
pdfOpts.Compliance = PdfCompliance.PdfA1b;
saveOptions.PdfOptions = pdfOpts;
PdfConverter.Process(loadOptions, saveOptions);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) + ".pdf");
PdfConverter.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/LowCodePdfSaveOptionsonce and reuse in loops. - Large files: Use stream-based processing to minimize memory allocation.
Common Issues and Resolutions
| Issue | Resolution |
|---|---|
| File not found | Verify path is correct; use absolute paths in production |
| Unsupported format | Check supported formats list; ensure file extension matches content |
| Evaluation watermark | Apply a valid license before processing |
| Memory errors on large files | Switch to stream-based processing |
API Reference
PdfConverter— Main converter classLowCodeLoadOptions— Input configurationLowCodePdfSaveOptions— Output configuration
See Also
- Getting Started
- Developer Guide
- Diagram Converter — For Visio-to-Visio format conversions