Learn how to Convert VSD to PDF in C# Using Aspose.Diagram for .NET
Last active
October 17, 2025 17:05
-
-
Save aspose-com-gists/926b53b12f15dbd7a41bda801af07fbb to your computer and use it in GitHub Desktop.
Convert VSD to PDF in C# Using Aspose.Diagram for .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Diagram; | |
// Step 1: Load the source VSD file | |
Diagram diagram = new Diagram("Drawing1.vsd"); | |
// Step 2: Save the file as PDF | |
diagram.Save("Drawing1_out.pdf", SaveFileFormat.Pdf); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Diagram; | |
// Get all .vsd files from the target folder. | |
string[] files = Directory.GetFiles("D:\\Files\\", "*.vsd"); | |
// Iterate through each Visio file path returned above. | |
foreach (var file in files) | |
{ | |
// Load the Visio diagram into memory from the current file path. | |
Diagram diagram = new Diagram(file); | |
// Build the output PDF file path by replacing the original extension with .pdf | |
string pdfFile = Path.ChangeExtension(file, ".pdf"); | |
// Save the currently loaded diagram as a PDF file to the computed path. | |
diagram.Save(pdfFile, SaveFileFormat.Pdf); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Diagram; | |
using Aspose.Diagram.Saving; | |
// 1) Load the source Visio diagram from disk. | |
Diagram diagram = new Diagram("sample.vsd"); | |
// 2) Prepare PDF save options | |
PdfSaveOptions options = new PdfSaveOptions | |
{ | |
// Include both foreground and background pages in the PDF. | |
// Set to true if you only want the main content pages. | |
SaveForegroundPagesOnly = false, | |
// Produce a PDF/A-1b compliant document. | |
Compliance = PdfCompliance.PdfA1b, | |
// Use the highest JPEG quality for any rasterized content inside pages. | |
// Lower this value if you need a smaller output file size. | |
JpegQuality = 100 | |
}; | |
// 3) Export the diagram to PDF. | |
diagram.Save("save-diagram.pdf", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Diagram; | |
// Load the VSD diagram | |
Diagram diagram = new Diagram("Sample.vsd"); | |
// Initialize PDF save options | |
PdfSaveOptions options = new PdfSaveOptions | |
{ | |
PageIndex = 1, // Export second page (index starts from 0) | |
PageCount = 1 // Export only one page | |
}; | |
// Save the specific page as PDF | |
diagram.Save("specific-page.pdf", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Diagram; | |
// Load the VSD file in stream | |
using (FileStream inputStream = new FileStream("sample.vsd", FileMode.Open)) | |
{ | |
// Load VSD from stream | |
Diagram diagram = new Diagram(inputStream); | |
using (FileStream outputStream = new FileStream("diagram-stream.pdf", FileMode.Create)) | |
{ | |
// Save PDF to stream | |
diagram.Save(outputStream, SaveFileFormat.Pdf); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment