Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active October 27, 2021 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/522b29f900577e1c8b339b42f4b5caa5 to your computer and use it in GitHub Desktop.
Save aspose-cloud/522b29f900577e1c8b339b42f4b5caa5 to your computer and use it in GitHub Desktop.
This Gist contains code snippets related to conversion VTX file to JPG format using Aspose.Diagram Cloud SDK for .NET
This Gist contains code snippets related to conversion VTX file to JPG format using Aspose.Diagram Cloud SDK for .NET
// Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44";
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553";
// create an object of DiagramApi
DiagramApi diagramApi = new DiagramApi("client_credentials", clientID, clientSecret);
// input VSSX file name
String inputFile = "MVPSession1SimpleTimeline.vtx";
// resultant file format
String newFormat = "JPEG";
// name of output file
String newFileName = "Converted.jpeg";
try
{
// read the input VTX file from local drive
using (var inputStream = System.IO.File.OpenRead(@"C:\Users\shahbnay\Downloads\" + inputFileName))
{
// create a Storage class instance
StorageApi storageApi = new StorageApi("client_credentials", clientID, clientSecret);
// upload input VTX file to cloud storage
storageApi.UploadFile(inputFileName, inputStream);
// initiate the file conversion process
var response = diagramApi.DownloadFileWithFormat(inputFileName, format: newFormat, null);
if (response != null)
{
Console.WriteLine("Successfully converted VTX to JPEG !");
}
// custom method to save resultant file on local system drive
saveToDisk(response, "C:\\Users\\Downloads\\" + newFileName);
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment