Skip to content

Commit 8e7a931

Browse files
Update README.md
1 parent 2b60248 commit 8e7a931

File tree

1 file changed

+62
-37
lines changed

1 file changed

+62
-37
lines changed

README.md

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

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

@@ -47,61 +47,86 @@ dependencies {
4747
}
4848
```
4949

50-
## Getting Started
50+
### Create an account
51+
Creating an account is very simple. Go to Dashboard to create a free account.
52+
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).
5153

52-
* Please follow the [installation](#installation) instruction
53-
* Get your AppSID and AppKey at [Dashboard](https://dashboard.groupdocs.cloud) and use them in your code
54-
* Build and execute
55-
* Explore more samples at [GitHub](https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-java-samples)
54+
### Create an API client app
55+
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).
5656

57-
Example:
57+
## Convert document
5858

5959
```java
6060
import com.groupdocs.cloud.conversion.client.*;
61-
import com.groupdocs.cloud.conversion.model.*;
62-
import com.groupdocs.cloud.conversion.api.InfoApi;
63-
61+
import com.groupdocs.cloud.conversion.model.requests.*;
62+
import com.groupdocs.cloud.conversion.api.*;
63+
import java.io.File;
6464
import java.util.*;
6565

6666
public class ApiExample {
6767

6868
public static void main(String[] args) {
69-
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
70-
String appSid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
71-
String appKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
72-
73-
Configuration configuration = new Configuration(appSid, appKey);
74-
75-
InfoApi infoApi = new InfoApi(configuration);
76-
77-
try {
78-
FormatsResult response = infoApi.getSupportedFileFormats();
79-
for (Format format : response.getFormats()) {
80-
System.out.println(format.getFileFormat());
81-
}
82-
} catch (ApiException e) {
83-
System.err.println("Failed to get supported file formats");
84-
e.printStackTrace();
85-
}
69+
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required).
70+
String ClientId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
71+
String ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
72+
73+
Configuration configuration = new Configuration(ClientId, ClientSecret);
74+
75+
ConvertApi apiInstance = new ConvertApi(configuration);
76+
77+
File file = new File("myFile.docx");
78+
79+
ConvertDocumentDirectRequest request = new ConvertDocumentDirectRequest("pdf", file, 1, 0, null, null);
80+
81+
File result = apiInstance.convertDocumentDirect(request);
82+
83+
System.out.println("Document converted: " + result.length());
8684
}
8785
}
8886
```
8987

90-
## Manual build and installation from sources
88+
## Convert document using cloud storage
89+
90+
```java
91+
import com.groupdocs.cloud.conversion.client.*;
92+
import com.groupdocs.cloud.conversion.model.requests.*;
93+
import com.groupdocs.cloud.conversion.api.*;
94+
import java.io.File;
95+
import java.util.*;
96+
97+
public class ApiExample {
9198

92-
Building the API client library requires [Maven](https://maven.apache.org/) to be installed.
93-
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
99+
public static void main(String[] args) {
100+
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required).
101+
String ClientId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
102+
String ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
94103

95-
At first generate the JAR by executing following command in "/src" working directory:
104+
Configuration configuration = new Configuration(ClientId, ClientSecret);
96105

97-
```shell
98-
mvn package -D maven.test.skip=true
99-
```
106+
FileApi fileApiInstance = new FileApi(configuration);
107+
ConvertApi apiInstance = new ConvertApi(configuration);
100108

101-
Then manually install the following JARs:
109+
// Upload file to cloud storage
110+
File file = new File("myFile.docx");
111+
UploadFileRequest request = new UploadFileRequest("myFile.docx", file, null);
112+
fileApiInstance.uploadFileWithHttpInfo(request);
102113

103-
* target/groupdocs-conversion-cloud-25.6.jar
104-
* target/lib/*.jar
114+
// Convert document
115+
ConvertSettings settings = new ConvertSettings();
116+
settings.setFilePath("myFile.docx");
117+
settings.setFormat("pdf");
118+
settings.setOutputPath("converted");
119+
120+
List<StoredConvertedResult> result = apiInstance.convertDocument(new ConvertDocumentRequest(settings));
121+
System.out.println("Document converted: " + result.get(0).getUrl());
122+
123+
// Download the result
124+
DownloadFileRequest request = new DownloadFileRequest("converted/myFile.pdf", null, null);
125+
File response = fileApiInstance.downloadFile(request);
126+
System.err.println("Expected response type is File: " + response.length());
127+
}
128+
}
129+
```
105130

106131
## Licensing
107132

0 commit comments

Comments
 (0)