Skip to content

Commit 1245f5f

Browse files
author
Tomas Rutkauskas
authored
Update Getting-Started.md
1 parent fd5cf72 commit 1245f5f

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

Getting-Started.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,109 @@
1+
# ConvertAPI Java Client
2+
## Convert your files with our online file conversion API
13

4+
The ConvertAPI helps converting various file formats.
5+
Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes.
6+
Merge, Encrypt, Split, Repair and Decrypt PDF files.
7+
And many others files manipulations.
8+
In just few minutes you can integrate it into your application and use it easily.
9+
10+
The ConvertAPI-Java library makes it easier to use the Convert API from your Java 8 projects without having to build your own API calls.
11+
You can get your free API secret at https://www.convertapi.com/a
12+
13+
## Installation
14+
15+
Download **[latest JAR file](https://github.com/ConvertAPI/convertapi-java/releases/download/v1.5/convertapi-1.5.jar)** and place it in your project library directory.
16+
17+
## Usage
18+
19+
### Configuration
20+
21+
You can get your secret at https://www.convertapi.com/a
22+
23+
```java
24+
Config.setDefaultSecret("your api secret");
25+
```
26+
27+
### File conversion
28+
29+
Example to convert DOCX file to PDF. All supported formats and options can be found
30+
[here](https://www.convertapi.com).
31+
32+
```java
33+
CompletableFuture<ConversionResult> result = ConvertApi.convert("docx", "pdf", new Param("file", Paths.get("test.docx")));
34+
35+
// save to file
36+
result.get().saveFile(Paths.get("my_file.pdf")).get();
37+
```
38+
39+
Other result operations:
40+
41+
```java
42+
// save all result files to folder
43+
result.get().saveFiles(Paths.get("/tmp"));
44+
45+
// get result file
46+
ConversionResultFile file = result.get().getFile(0);
47+
48+
// get conversion cost
49+
Integer cost = result.get().conversionCost();
50+
```
51+
52+
#### Convert file url
53+
54+
```java
55+
CompletableFuture<ConversionResult> result = ConvertApi.convert("pptx", "pdf",
56+
new Param("file", "https://cdn.convertapi.com/cara/testfiles/presentation.pptx")
57+
);
58+
```
59+
60+
#### Additional conversion parameters
61+
62+
ConvertAPI accepts extra conversion parameters depending on converted formats. All conversion
63+
parameters and explanations can be found [here](https://www.convertapi.com).
64+
65+
```java
66+
CompletableFuture<ConversionResult> result = ConvertApi.convert("pdf", "jpg",
67+
new Param("file", Paths.get("test.pdf")),
68+
new Param("scaleimage", "true"),
69+
new Param("scaleproportions", "true"),
70+
new Param("imageheight", 300)
71+
);
72+
```
73+
74+
### User information
75+
76+
You can always check remaining seconds amount by fetching [user information](https://www.convertapi.com/doc/user).
77+
78+
```java
79+
User user = ConvertApi.getUser();
80+
int secondsLeft = user.SecondsLeft;
81+
```
82+
83+
### More examples
84+
85+
You can find more advanced examples in the [examples](https://github.com/ConvertAPI/convertapi-java/tree/master/src/main/java/com/convertapi/examples) folder.
86+
87+
#### Converting your first file, full example:
88+
89+
ConvertAPI is designed to make converting file super easy, the following snippet shows how easy it is to get started. Let's convert WORD DOCX file to PDF:
90+
91+
```java
92+
import com.convertapi.ConvertApi;
93+
94+
public class SimpleConversion {
95+
public static void main(String[] args) {
96+
ConvertApi.convert("source.docx", "result.pdf", "YOUR API SECRET");
97+
}
98+
}
99+
```
100+
101+
This is the bare-minimum to convert a file using the ConvertAPI client, but you can do a great deal more with the ConvertAPI Java library.
102+
Take special note that you should replace `YOUR API SECRET` with the secret you obtained in item two of the pre-requisites.
103+
104+
### Issues &amp; Comments
105+
Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!
106+
107+
### License
108+
The ConvertAPI Java Library is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php "Read more about the MIT license form") license.
109+
Refer to the [LICENSE](https://github.com/ConvertAPI/convertapi-java/blob/master/LICENSE) file for more information.

0 commit comments

Comments
 (0)