Create VSTX Documents via C#
Native and high performance VSTX (Portable Document Format) creation programmatically using server side .NET APIs.
Generating VSTX file dynamically within running application is easy. In order to create VSTX documents from scratch without requiring MS Office, we’ll use
API that offers different features for visio creation, manipulation and conversion using .NET platform. Developers can easily enhance code for writing data, generating shapes or graphs.
How to Create VSTX via C#
It is easy for the developers to create, load, modify and convert VSTX within running different reporting applications for data processing in just a few lines of code.
- Include the namespace in your class file
- Create Diagram class instance.
- Access the first page of the diagram.
- Add text in the page.
- Use Save method to save the diagram as VSTX file.
System Requirements
Just make sure that system have Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Azure, Mono Platforms as well as development environment like Microsoft Visual Studio.
- Install from command line as
nuget install Aspose.Diagram
or via Package Manager Console of Visual Studio withInstall-Package Aspose.Diagram
. - Alternatively, get the offline MSI installer or all DLLs in a ZIP file from downloads
Following source code shows how to create a VSTX file using C#.
// Create Diagram class instance.
Diagram diagram = new Diagram();
// Access the first page of the diagram.
Page page = diagram.Pages[0];
// Add Text shape.
Shape shape = page.AddText(1, 1, 1, 1, "Test text", "Calibri", "#a5a5a5", 0.25);
// Save the Diagram as .vstx file.
diagram.Save("out.vstx",SaveFileFormat.VSTX);
VSTX What is VSTX File Format?
Files with VSTX extensions are drawing template files created with Microsoft Visio 2013 and above. These VSTX files provide starting point for creating Visio drawings, saved as .VSDX files, with default layout and settings. In general, Visio files are used to create drawings that contain visual objects, flow charts, UML diagram, information flow, organizational charts, software diagrams, network layout, database models, objects mapping and other similar information. Files generated using Visio can also be exported to different file formats such as PNG, BMP, PDF and others. Programs that open VSTX files include Microsoft Visio for Windows and Mac that let you open these files for viewing and editing. It also allows to convert Visio file formats to a number of other formats.
Read MoreOther Supported Visio Generation
You can also create other Microsoft Visio formats including few listed below.