Skip to content

Commit fe389ac

Browse files
Update README.md
1 parent 2f55d53 commit fe389ac

1 file changed

Lines changed: 65 additions & 20 deletions

File tree

README.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GroupDocs.Conversion Cloud SDK for Android
22

3-
This repository contains GroupDocs.Conversion Cloud SDK for Android source code. This SDK allows you to work with GroupDocs.Conversion Cloud REST APIs in your Android applications on Java language.
3+
This repository contains GroupDocs.Conversion Cloud SDK for Android 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
## Installation
66

@@ -29,38 +29,83 @@ dependencies {
2929
}
3030
```
3131

32-
## Getting Started
32+
### Create an account
33+
Creating an account is very simple. Go to Dashboard to create a free account.
34+
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).
3335

34-
Please follow the [installation](#installation) instruction and use the following Java code:
36+
### Create an API client app
37+
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).
38+
39+
## Convert document
3540

3641
```java
3742
import com.groupdocs.cloud.conversion.client.*;
38-
import com.groupdocs.cloud.conversion.model.*;
39-
import com.groupdocs.cloud.conversion.api.InfoApi;
43+
import com.groupdocs.cloud.conversion.model.requests.*;
44+
import com.groupdocs.cloud.conversion.api.*;
45+
import java.io.File;
46+
import java.util.*;
47+
48+
public class ApiExample {
49+
50+
public static void main(String[] args) {
51+
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required).
52+
String ClientId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
53+
String ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
54+
55+
Configuration configuration = new Configuration(ClientId, ClientSecret);
4056

57+
ConvertApi apiInstance = new ConvertApi(configuration);
58+
59+
File file = new File("myFile.docx");
60+
61+
ConvertDocumentDirectRequest request = new ConvertDocumentDirectRequest("pdf", file, 1, 0, null, null);
62+
63+
File result = apiInstance.convertDocumentDirect(request);
64+
65+
System.out.println("Document converted: " + result.length());
66+
}
67+
}
68+
```
69+
70+
## Convert document using cloud storage
71+
72+
```java
73+
import com.groupdocs.cloud.conversion.client.*;
74+
import com.groupdocs.cloud.conversion.model.requests.*;
75+
import com.groupdocs.cloud.conversion.api.*;
76+
import java.io.File;
77+
import java.util.*;
4178

4279
public class ApiExample {
4380

44-
public static void getSupportedFormats() {
81+
public static void main(String[] args) {
82+
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required).
83+
String ClientId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
84+
String ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
85+
86+
Configuration configuration = new Configuration(ClientId, ClientSecret);
4587

46-
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
47-
String appSid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
48-
String appKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
88+
FileApi fileApiInstance = new FileApi(configuration);
89+
ConvertApi apiInstance = new ConvertApi(configuration);
4990

50-
Configuration configuration = new Configuration(appSid, appKey);
91+
// Upload file to cloud storage
92+
File file = new File("myFile.docx");
93+
UploadFileRequest request = new UploadFileRequest("myFile.docx", file, null);
94+
fileApiInstance.uploadFileWithHttpInfo(request);
5195

52-
InfoApi infoApi = new InfoApi(configuration);
96+
// Convert document
97+
ConvertSettings settings = new ConvertSettings();
98+
settings.setFilePath("myFile.docx");
99+
settings.setFormat("pdf");
100+
settings.setOutputPath("converted");
53101

54-
try {
55-
FormatsResult response = infoApi.getSupportedFileFormats();
56-
for (Format format : response.getFormats()) {
57-
System.out.println(format.getFileFormat());
58-
}
59-
} catch (ApiException e) {
60-
System.err.println("Failed to get supported file formats");
61-
e.printStackTrace();
62-
}
102+
List<StoredConvertedResult> result = apiInstance.convertDocument(new ConvertDocumentRequest(settings));
103+
System.out.println("Document converted: " + result.get(0).getUrl());
63104

105+
// Download the result
106+
DownloadFileRequest request = new DownloadFileRequest("converted/myFile.pdf", null, null);
107+
File response = fileApiInstance.downloadFile(request);
108+
System.err.println("Expected response type is File: " + response.length());
64109
}
65110
}
66111
```

0 commit comments

Comments
 (0)