|
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet |
|
// Obtain your API credentials |
|
string clientId = "4bdefca3-f08c-4088-9ca0-55c38f4b7f22"; |
|
string clientSecret1 = "a43c8b4365246a062688a259abe5b469"; |
|
|
|
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret. |
|
var configurations = new GroupDocs.Conversion.Cloud.Sdk.Client.Configuration(clientId, clientSecret1); |
|
// Define the value of ApiBaseUrl to set the base url of PDF to XLS conversion API. |
|
configuration.ApiBaseUrl = "https://api.groupdocs.cloud"; |
|
|
|
// Initialize an instance of the ConvertApi class with the object of the Configuration class. |
|
var apiInstance = new GroupDocs.Conversion.Cloud.Sdk.Api.ConvertApi(configurations); |
|
|
|
// read the content of input PDF file from local drive |
|
using (var stream = System.IO.File.OpenRead("marketing.pdf")) |
|
{ |
|
// create an instance of FileApi |
|
var fileUpload = new FileApi(configurations); |
|
// upload the input PDF to cloud storage |
|
fileUpload.UploadFile(new UploadFileRequest("marketing.pdf", stream)); |
|
|
|
// create ConvertSettings where we define the input PDF file and the name for resultant Excel worksheet |
|
var settings = new ConvertSettings |
|
{ |
|
StorageName = "internal", |
|
FilePath = "marketing.pdf", |
|
Format = "xls", |
|
OutputPath = "myResultant.xls" |
|
}; |
|
|
|
// Invoke the ConvertDocument method to initiate PDF to Excel conversion. |
|
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); |
|
if (response != null && response.Equals("OK")) |
|
{ |
|
// print success message |
|
Console.WriteLine("The PDF to Excel conversion completed successfully !"); |
|
} |
|
} |