VSD file format is the native format of the Microsoft Visio application and contains advanced diagrams and vector graphics. This format made the presentation of diagrams, organizational charts, and complicated flowcharts quite handly. However, in order to view these files, specific software such as Microsoft Visio, etc is required, and also, if we need to put these details over the webpage, it gets quite complicated. Therefore, we may opt to convert the VSD files to Scalable Vector Graphics (SVG) format. Once we have the SVG, it can be referenced directly into the HTML document using the <svg> </svg> tag. So in this article, we are going to discuss the conversion of VSD files to SVG images using .NET REST API.
- Visio files processing API
- VSD to SVG in C#
- Convert VSD to SVG using cURL command
Visio files processing API
Aspose.Diagram Cloud is our REST API enabling our users to create, edit and transform Visio files and flow charts to other supported formats. Perform all these operations without installing Microsoft Visio or other applications. Furthermore, we have created free SDKs as wrappers around Cloud API so that you can perform all document processing operations within the language of your choice. So. in this article, we are going to discuss the conversion operations using Aspose.Diagram Cloud SDK for .NET.
The first step in using the Cloud SDK is installation. It is available for download over NuGet and GitHub. You may consider executing the following command in the terminal to install the SDK via NuGet:
nuget install Aspose.Diagram-Cloud
NuGet Package Manager
Or execute the following command in Package Manager Console in Visual Studio to fetch & reference Aspose.Diagram assembly in your project.
PM> Install-Package Aspose.Diagram-Cloud
If you already have Aspose.Diagram Cloud SDK for .NET and want to upgrade it, please execute to get the latest version.
Another approach is the installation directly within Visual Studio solution:
- Open the Solution Explorer.
- Expand the project and Right-click Packages folder within your solution.
- Select Manage NuGet Packages… option
- Click on the Browse tab and search for “Aspose.Diagram-Cloud“.
- Click on the Aspose.Diagram-Cloud package, select the appropriate version in the right-tab and click Add Package button.
After the installation, the next major step in setup and configuration is a free account subscription over Aspose.Cloud dashboard. No credit card or other payment details are required and under a free subscription account, you can perform up to 150 Free document processing requests. So if you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
VSD to SVG in C#
Please follow the instructions specified below to convert VSD files to SVG format using the C# .NET code snippet. Please note that this code snippet expects that the input VSD file shall be in cloud storage.
- First of all, use string variables to define Client Credetials
- Secondly, create an instance of DiagramApi while passing Client Credentials details as argument
- Thridly, call DownloadFileWithFormat(..) method of DiagramApi to perform the conversion operation
- Finally, use the File.Create object (as shown in saveToDisk method) to save output on local system
Convert VSD to SVG using cURL command
Since our APIs are developed according to REST architecture, so they can also be accessed through the cURL commands. Also, please note that in order to access the APIs, we need to generate a JWT access token based on our personalized client credentials. Please execute the following command for JWT access token generation.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=4ccf1790-accc-41e9-8d18-a78dbb2ed1aa&client_secret=caac6e3d4a4724b2feb53f4e460eade3" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
Once we have the JWT token, we can perform the conversion using the following command.
curl -X GET "https://api.aspose.cloud/v3.0/diagram/Raise-PO-Process-Flow-Chart.vsd?format=SVG" \ -H "accept: multipart/form-data" \ -H "authorization: Bearer <JWT Token>" \ -o Converted.svg
In this article, we have discussed the simple steps on how to load VSD file from cloud storage and render it to SVG format. We have discussed the conversion using C# .NET and cURL command. Furthermore, the SDKs are offered under an MIT license and can be downloaded from GitHub. In case you encounter any issue while using the API or you have any related query, please feel free to contact via the Free Support forum.
In order to view the VSD files, you may try using our Free Online Visio Viewer.
We also recommend visiting the following links to learn more about