Skip to content

Commit e5d835c

Browse files
Update README.md
1 parent 0013630 commit e5d835c

1 file changed

Lines changed: 67 additions & 21 deletions

File tree

README.md

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# GroupDocs.Conversion Cloud SDK for .NET
22

3-
This repository contains GroupDocs.Conversion Cloud SDK for .NET source code. This SDK allows you to work with GroupDocs.Conversion Cloud REST APIs in your .NET applications.
3+
This repository contains GroupDocs.Conversion Cloud SDK for .NET source code. This SDK has been developed to help you get started with using our document conversion REST API, allowing to seamlessly convert your documents to any format you need. With this single API, you can convert back and forth between over 50 types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and many more.
44

55
## How to use the SDK
66

77
The complete source code is available in this repository folder, you can either directly use it in your project via NuGet package manager. For more details, please visit our [documentation website](https://docs.groupdocs.cloud/display/conversioncloud/Available+SDKs#AvailableSDKs-.NET).
88

9-
## Dependencies
9+
### Create an account
10+
Creating an account is very simple. Go to Dashboard to create a free account.
11+
We’re using Single Sign On across our websites, therefore, if you already have an account with our services, you can use it to also acccess the [Dashboard](https://dashboard.groupdocs.cloud).
1012

11-
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json)
13+
### Create an API client app
14+
Before you can make any requests to GroupDocs Cloud API you need to get a Client Id and a Client Secret. This will will be used to invoke GroupDocs Cloud API. You can get it by creating a new [Application](https://dashboard.groupdocs.cloud/applicationsV).
1215

13-
## Getting Started
16+
## Convert document
1417

1518
```csharp
1619
using System;
@@ -23,26 +26,69 @@ namespace Example
2326
{
2427
public void Main()
2528
{
26-
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
27-
var appSid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
28-
var appKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
29+
// For complete examples and data files, please go to https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet-samples
30+
string MyClientSecret = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
31+
string MyClientId = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
32+
33+
var configuration = new Configuration(MyClientId, MyClientSecret);
34+
35+
// Create necessary API instances
36+
var apiInstance = new ConvertApi(configuration);
37+
38+
// Prepare request
39+
var fileStream = File.Open("myFile.docx", FileMode.Open);
40+
var request = new ConvertDocumentDirectRequest("pdf", fileStream);
41+
42+
// Convert to specified format
43+
var response = apiInstance.ConvertDocumentDirect(request);
44+
Console.WriteLine("Document converted successfully: " + response.Length);
45+
}
46+
}
47+
}
48+
```
2949

30-
var api = new InfoApi(appSid, appKey);
50+
## Convert document using cloud storage
3151

32-
try
33-
{
34-
// Get supported file formats
35-
var formats = api.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
36-
37-
foreach (var format in formats)
38-
{
39-
Debug.Print(format.SourceFormat);
40-
}
41-
}
42-
catch (Exception e)
52+
```csharp
53+
using System;
54+
using System.Diagnostics;
55+
using GroupDocs.Conversion.Cloud.Sdk.Api;
56+
57+
namespace Example
58+
{
59+
public class Example
60+
{
61+
public void Main()
62+
{
63+
// For complete examples and data files, please go to https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet-samples
64+
string MyClientSecret = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
65+
string MyClientId = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
66+
67+
var configuration = new Configuration(MyClientId, MyClientSecret);
68+
69+
// Create necessary API instances
70+
var fileApi = new FileApi(configuration);
71+
var convertApi = new ConvertApi(configuration);
72+
73+
// Upload file to cloud storage
74+
var fileStream = File.Open("myFile.docx", FileMode.Open);
75+
fileApi.UploadFile(new UploadFileRequest("myFile.docx", fileStream));
76+
77+
// Prepare convert settings
78+
var settings = new ConvertSettings
4379
{
44-
Debug.Print("Something went wrong: " + e.Message);
45-
}
80+
FilePath = "myFile.docx",
81+
Format = "pdf",
82+
OutputPath = "converted"
83+
};
84+
85+
// Convert to specified format
86+
apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
87+
88+
// Download the result
89+
90+
var response = apiInstance.DownloadFile(new DownloadFileRequest("converted/myFile.pdf");
91+
Console.WriteLine("Expected response type is Stream: " + response.Length.ToString());
4692
}
4793
}
4894
}

0 commit comments

Comments
 (0)