Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist contains code snippets related to conversion of PDF files to DOC format using Aspose.Words Cloud SDK for .NET
This gist contains code snippets related to conversion of PDF files to DOC format using Aspose.Words Cloud SDK for .NET
// Get client credentials from https://dashboard.aspose.cloud/
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44";
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553";
// create configuration object using ClinetID and Client Secret details
var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
// initialize WordsApi instance
var wordsApi = new WordsApi(config);
// input file name
String inputFile = "awesome_table_in_pdf.pdf";
// name of resultant file
String resultant = "conveted.doc";
// resultant file format
String format = "DOC";
try
{
// load the file from local drive
using (var file = System.IO.File.OpenRead(@"C:\Users\shahbnay\Downloads\" + inputFile))
{
var uploadFileRequest = new UploadFileRequest(file, inputFile);
// upload file to Cloud storage
wordsApi.UploadFile(uploadFileRequest);
}
// create DocumentWithFormat request object
var response = new GetDocumentWithFormatRequest(inputFile, format,outPath: resultant);
// trigger the document operation
wordsApi.GetDocumentWithFormat(response);
// print success message if conversion is successful
if (response != null && response.Equals("OK"))
{
Console.WriteLine("PDF file successfully converted to DOC !");
Console.ReadKey();
}
}catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment