MS Visio is a widely used application for creating a multitude of diagrams such as flowcharts, business flow diagrams, etc. However, in various cases, you may need to convert the diagram files to other file formats. For example, when sharing the diagrams you can convert them to a PDF file. On the other hand, you can convert a diagram to an image for embedding it into your web or desktop application. In this article, we will target Visio diagram to PDF conversion programmatically. Particularly, you will learn how to convert VSDX or VSD files to PDF using C#.
- C# Visio to PDF Converter API
- Steps to Convert Visio to PDF
- C# Visio to PDF - Complete Code
- Get Free License
C# Visio to PDF Converter API
Aspose.Diagram for .NET is a C# class library that is designed to create and manipulate MS Visio diagrams from within the .NET applications. Furthermore, it provides a high fidelity converter API that allows you to convert Visio diagrams to PDF and other formats. You can either download the API’s DLL or install it using NuGet.
Install-Package Aspose.Diagram
Steps to Convert Visio to PDF in C#
The following are the steps to convert a Visio diagram to PDF using Aspose.Diagram for .NET.
- Load Visio VSD or VDSX file using Diagram class.
- Create a MemoryStream object.
- Convert Visio file to PDF and save it into MemoryStream object using Diagram.Save(MemoryStream, SaveFileFormat.PDF) method.
- Create a new FileStream object for the converted PDF file.
- Save the converted PDF using MemoryStream.WriteTo(FileStream) method.
- Close the MemoryStream and FileStream.
C# Visio to PDF - Complete Code
The following is the complete source code of how to convert a Visio file to PDF using C#.
Results
The following are the screenshots of the results you would obtain using the above-mentioned code.
Visio Diagram
Converted PDF
Get a Free License
You can get a free temporary license in order to try the API without evaluation limitations.
Conclusion
Aspose.Diagram for .NET provides a wide range of features for the manipulation of Visio diagrams. In addition, it provides high-quality conversion of diagrams to PDF format. In this article, you have learned how to convert the VDS or VSDX diagrams to PDF format using C#. You can explore more about the API using the documentation.