MS Visio is a popular application that lets you create a wide range of diagrams such as flowcharts, data flow diagrams, business process models and etc. VSDX is the file format that MS Visio uses to store the diagrams. In order to automate VSDX manipulation, this article provides you a basic tutorial of how to create Visio diagrams from scratch in C#. Furthermore, it covers how to insert pages, shapes, and text in the VSDX diagrams from within .NET applications.

C# Visio API - Free Download

Aspose.Diagram for .NET is a feature-rich API that lets you create, edit, convert, and process MS Visio diagrams from within your .NET applications. The API makes it easier for you to manipulate the VSDX diagrams with easy to use properties and methods. You can either download API’s DLL or get it installed within your .NET applications using NuGet.

Install-Package Aspose.Diagram

Create Visio VSDX Diagram using C#

First of all, let’s create an empty VSDX diagram from scratch. The following are the steps to do so:

The following code sample shows how to create Visio VSDX diagram in C#.

Add Master to Visio Diagram in C#

Master is used to add the stencil which contains a collection of shapes to be used in diagrams. If you want to add the master, you need a VSS stencil file and master ID. The following are the steps to add a master to the Visio diagram using Aspose.Diagram.

The following code sample shows how to add a master to the Visio diagram using C#.

For more details, please visit working with master.

Insert Pages in a Visio Diagram in C#

MS Visio diagrams consist of one or more pages and each page contains the diagrams. Therefore, before adding a shape, you need to add a page using the following steps.

The following code sample shows how to add a page in Visio VSDX diagram using C#.

For more details, please visit working with pages.

Create a Shape in Visio Diagram using C#

Shapes are the building blocks of the Visio diagrams. MS Visio supports a wide range of shapes to create diagrams in various domains. The following steps show how to insert a shape in Visio Diagram.

The following code sample shows how to add a shape in the Visio diagram using C#.

For more details, please visit working with shapes.

Add a Text Shape in the Visio Page in C#

In various cases, you also need to add text to the Visio diagrams. For this, you can follow the below steps.

The following code sample shows how to add text in a VSDX diagram using C#.

For more details, please visit working with text.

Conclusion

In this post, you have learned some basic features of Aspose.Diagram for .NET to create Visio VSDX diagrams from scratch. The code samples have shown how to add masters, pages, shapes, and text in VSDX diagrams using C#. You can explore more about the API using the documentation.

See Also