Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active October 3, 2021 23:37
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/3196ff01ba0d7b9e4df430962d9d963d to your computer and use it in GitHub Desktop.
Save aspose-cloud/3196ff01ba0d7b9e4df430962d9d963d to your computer and use it in GitHub Desktop.
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