Skip to content

Commit 26b4e34

Browse files
authored
Merge pull request #6 from Api2Pdf/2.0.0
2.0.0
2 parents 568c1bf + fc41816 commit 26b4e34

13 files changed

+545
-591
lines changed

README.md

+87-40
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.api2pdf.client/api2pdf/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.api2pdf.client/api2pdf)
33

44
# api2pdf.java
5-
Java client for [Api2Pdf REST API](https://www.api2pdf.com/documentation)
5+
Java client for [Api2Pdf REST API](https://www.api2pdf.com/documentation/v2)
66

7-
Api2Pdf.com is a REST API for instantly generating PDF documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), and images. The API also supports merge / concatenation of two or more PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, and **LibreOffice**.
7+
Api2Pdf.com is a powerful REST API for instantly generating PDF and Office documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), Email files, and images. You can generate image preview or thumbnail of a PDF, office document, or email file. The API also supports merge / concatenation of two or more PDFs, setting passwords on PDFs, and adding bookmarks to PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, **PdfSharp**, and **LibreOffice**.
88

99
- [Installation](#installation)
1010
- [Resources](#resources)
@@ -21,7 +21,7 @@ The Java client library is available as a Maven Package and can be installed wit
2121
<dependency>
2222
<groupId>com.api2pdf.client</groupId>
2323
<artifactId>api2pdf</artifactId>
24-
<version>1.0.4</version>
24+
<version>2.0.0</version>
2525
</dependency>
2626
</dependencies>
2727

@@ -55,37 +55,37 @@ All usage starts by importing the api2pdf library and creating a new object.
5555
Once you initialize the client, you can make calls like so:
5656

5757
```
58-
Api2PdfResponse pdfResponse = a2pClient.headlessChromeFromHtml("<p>test</p>", true, "test.pdf");
59-
System.out.println(pdfResponse.getPdf());
58+
Api2PdfResponse response = a2pClient.chromeHtmlToPdf("<p>test</p>", true, "test.pdf");
59+
System.out.println(response.getFile());
6060
```
6161

6262
### Successful Result Format
6363

6464
{
65-
'pdf': 'https://link-to-pdf-only-available-for-24-hours',
66-
'mbIn': 0.08421039581298828,
67-
'mbOut': 0.08830547332763672,
68-
'cost': 0.00017251586914062501,
69-
'success': true,
70-
'error': null,
71-
'responseId': '6e46637a-650d-46d5-af0b-3d7831baccbb'
65+
'FileUrl': 'https://link-to-pdf-only-available-for-24-hours',
66+
'Seconds': 0.08421039581298828,
67+
'MbOut': 0.08830547332763672,
68+
'Cost': 0.00017251586914062501,
69+
'Success': true,
70+
'Error': null,
71+
'ResponseId': '6e46637a-650d-46d5-af0b-3d7831baccbb'
7272
}
7373

7474
### Failed Result Format
7575

7676
{
77-
'success': false,
78-
'error': 'some reason for the error',
79-
'responseId': '6e46637a-650d-46d5-af0b-3d7831baccbb'
77+
'Success': false,
78+
'Error': 'some reason for the error',
79+
'ResponseId': '6e46637a-650d-46d5-af0b-3d7831baccbb'
8080
}
8181

8282
## <a name="wkhtmltopdf"></a> wkhtmltopdf
8383

8484
**Convert HTML to PDF (load PDF in browser window (true or false) and specify a file name)**.
8585

8686
```
87-
Api2PdfResponse pdfResponse = a2pClient.wkhtmlToPdfFromHtml("<p>Hello, World</p>", true, "test.pdf");
88-
System.out.println(pdfResponse.getPdf());
87+
Api2PdfResponse response = a2pClient.wkhtmlHtmlToPdf("<p>Hello, World</p>", true, "test.pdf");
88+
System.out.println(response.getFile());
8989
```
9090

9191
**Convert HTML to PDF (use HashMap for advanced wkhtmltopdf settings)**
@@ -95,15 +95,15 @@ System.out.println(pdfResponse.getPdf());
9595
Map<String, String> options = new HashMap<String, String>();
9696
options.put("orientation", "landscape");
9797
options.put("pageSize", "A4");
98-
Api2PdfResponse pdfResponse = a2pClient.wkhtmlToPdfFromHtml("<p>Hello, World</p>", true, "test.pdf", options);
99-
System.out.println(pdfResponse.getPdf());
98+
Api2PdfResponse response = a2pClient.wkhtmlHtmlToPdf("<p>Hello, World</p>", true, "test.pdf", options);
99+
System.out.println(response.getFile());
100100
```
101101

102102
**Convert URL to PDF (load PDF in browser window (true or false) and specify a file name)**.
103103

104104
```
105-
Api2PdfResponse pdfResponse = a2pClient.wkhtmlToPdfFromUrl("https://www.github.com", true, "test.pdf");
106-
System.out.println(pdfResponse.getPdf());
105+
Api2PdfResponse response = a2pClient.wkhtmlUrlToPdf("https://www.github.com", true, "test.pdf");
106+
System.out.println(response.getFile());
107107
```
108108

109109
**Convert URL to PDF (use HashMap for advanced wkhtmltopdf settings)**
@@ -113,8 +113,8 @@ System.out.println(pdfResponse.getPdf());
113113
Map<String, String> options = new HashMap<String, String>();
114114
options.put("orientation", "landscape");
115115
options.put("pageSize", "A4");
116-
Api2PdfResponse pdfResponse = a2pClient.wkhtmlToPdfFromUrl("https://www.github.com", true, "test.pdf", options);
117-
System.out.println(pdfResponse.getPdf());
116+
Api2PdfResponse response = a2pClient.wkhtmlUrlToPdf("https://www.github.com", true, "test.pdf", options);
117+
System.out.println(response.getFile());
118118
```
119119

120120
---
@@ -124,8 +124,8 @@ System.out.println(pdfResponse.getPdf());
124124
**Convert HTML to PDF (load PDF in browser window (true or false) and specify a file name)**
125125

126126
```
127-
Api2PdfResponse pdfResponse = a2pClient.headlessChromeFromHtml("<p>Hello World</p>", true, "test.pdf");
128-
System.out.println(pdfResponse.getPdf());
127+
Api2PdfResponse response = a2pClient.chromeHtmlToPdf("<p>Hello World</p>", true, "test.pdf");
128+
System.out.println(response.getFile());
129129
```
130130

131131
**Convert HTML to PDF (use HashMap for advanced Headless Chrome settings)**
@@ -134,15 +134,15 @@ System.out.println(pdfResponse.getPdf());
134134
```
135135
Map<String, String> options = new HashMap<String, String>();
136136
options.put("landscape", "true");
137-
Api2PdfResponse pdfResponse = a2pClient.headlessChromeFromHtml("<p>Hello World</p>", true, "test.pdf", options);
138-
System.out.println(pdfResponse.getPdf());
137+
Api2PdfResponse response = a2pClient.chromeHtmlToPdf("<p>Hello World</p>", true, "test.pdf", options);
138+
System.out.println(response.getFile());
139139
```
140140

141141
**Convert URL to PDF (load PDF in browser window (true or false) and specify a file name)**
142142

143143
```
144-
Api2PdfResponse pdfResponse = a2pClient.headlessChromeFromUrl("https://www.github.com", true, "test.pdf");
145-
System.out.println(pdfResponse.getPdf());
144+
Api2PdfResponse response = a2pClient.chromeUrlToPdf("https://www.github.com", true, "test.pdf");
145+
System.out.println(response.getFile());
146146
```
147147

148148
**Convert URL to PDF (use HashMap for advanced Headless Chrome settings)**
@@ -151,37 +151,84 @@ System.out.println(pdfResponse.getPdf());
151151
```
152152
Map<String, String> options = new HashMap<String, String>();
153153
options.put("landscape", "true");
154-
Api2PdfResponse pdfResponse = a2pClient.headlessChromeFromUrl("https://www.github.com", true, "test.pdf", options);
155-
System.out.println(pdfResponse.getPdf());
154+
Api2PdfResponse response = a2pClient.chromeUrlToPdf("https://www.github.com", true, "test.pdf", options);
155+
System.out.println(response.getFile());
156156
```
157+
158+
**Convert HTML to Image (load PDF in browser window (true or false) and specify a file name)**
159+
160+
```
161+
Api2PdfResponse response = a2pClient.chromeHtmlToImage("<p>Hello World</p>", true, "test.png");
162+
System.out.println(response.getFile());
163+
```
164+
165+
**Convert URL to Image (load PDF in browser window (true or false) and specify a file name)**
166+
167+
```
168+
Api2PdfResponse response = a2pClient.chromeUrlToImage("https://www.github.com", true, "test.png");
169+
System.out.println(response.getFile());
170+
```
157171

158172
---
159173

160174
## <a name="libreoffice"></a>LibreOffice
161175

162-
LibreOffice supports the conversion to PDF from the following file formats:
163-
164-
- doc, docx, xls, xlsx, ppt, pptx, gif, jpg, png, bmp, rtf, txt, html
176+
Convert any office file to PDF, image file to PDF, email file to PDF, HTML to Word, HTML to Excel, and PDF to HTML. Any file that can be reasonably opened by LibreOffice should be convertible. Additionally, we have an endpoint for generating a *thumbnail* of the first page of your PDF or Office Document. This is great for generating an image preview of your files to users.
165177

166178
You must provide a url to the file. Our engine will consume the file at that URL and convert it to the PDF.
167179

168180
**Convert Microsoft Office Document or Image to PDF (load PDF in browser window (true or false) and specify a file name)**
169181

170182
```
171-
Api2PdfResponse pdfResponse = a2pClient.libreofficeConvert("https://your-url-to-file", true, "test.pdf");
172-
System.out.println(pdfResponse.getPdf());
183+
Api2PdfResponse response = a2pClient.libreofficeAnyToPdf("https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx", true, "test.pdf");
184+
System.out.println(response.getFile());
173185
```
174-
186+
187+
**Thumbnail or Image Preview of a PDF or Office Document or Email file**
188+
189+
```
190+
Api2PdfResponse response = a2pClient.libreofficeThumbnail("https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx", true, "test.png");
191+
System.out.println(response.getFile());
192+
```
193+
194+
**Convert HTML to Microsoft Word or Docx**
195+
196+
```
197+
Api2PdfResponse response = a2pClient.libreofficeHtmlToDocx("http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html", true, "test.png");
198+
System.out.println(response.getFile());
199+
```
200+
201+
**Convert HTML to Microsoft Excel or Xlsx**
202+
203+
```
204+
Api2PdfResponse response = a2pClient.libreofficeHtmlToDocx("http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html", true, "test.docx");
205+
System.out.println(response.getFile());
206+
```
207+
208+
**Convert HTML to Microsoft Excel or Xlsx**
209+
210+
```
211+
Api2PdfResponse response = a2pClient.libreofficeHtmlToXlsx("http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html", true, "test.xlsx");
212+
System.out.println(response.getFile());
213+
```
214+
215+
**Convert PDF to HTML**
216+
217+
```
218+
Api2PdfResponse response = a2pClient.libreofficeHtmlToXlsx("http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf", true, "test.png");
219+
System.out.println(response.getFile());
220+
```
221+
175222
---
176223

177-
## <a name="merge"></a>Merge / Concatenate Two or More PDFs
224+
## <a name="merge"></a>PdfSharp
178225

179226
To use the merge endpoint, supply a list of urls to existing PDFs. The engine will consume all of the PDFs and merge them into a single PDF, in the order in which they were provided in the list.
180227

181228
**Merge PDFs from array of URLs to existing PDFs (load PDF in browser window (true or false) and specify a file name)****
182229

183230
```
184231
String[] urls = { "your-url-to-pdf1.pdf", "your-url-to-pdf2.pdf" };
185-
Api2PdfResponse pdfResponse = a2pClient.merge(urls, true, "test.pdf");
186-
System.out.println(pdfResponse.getPdf());
232+
Api2PdfResponse response = a2pClient.pdfsharpMerge(urls, true, "test.pdf");
233+
System.out.println(response.getFile());
187234
```

api2pdf/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
<artifactId>
1010
api2pdf
1111
</artifactId>
12-
<version>1.0.3</version>
12+
<version>2.0.0</version>
1313
<name>
1414
api2pdf
1515
</name>
1616
<description>
17-
Api2Pdf is a powerful PDF generation API with no rate limits or file size constraints.
18-
Generate PDFs from HTML, URLs, images, office documents, and more.
17+
This client library is a wrapper for the Api2Pdf.com REST API. See full REST api documentation at https://www.api2pdf.com/documentation/v2. Api2Pdf is a powerful API that supports HTML to PDF, URL to PDF, HTML to Image, URL to Image, Thumbnail / image preview of an Office file, Office files (Word to PDF), HTML to Docx, HTML to excel, PDF to HTML, merge PDFs together, add bookmarks to PDFs, add passwords to PDFs
1918
</description>
2019
<url>
2120
https://www.api2pdf.com/
@@ -75,7 +74,7 @@
7574
https://github.com/Api2Pdf/api2pdf.java
7675
</url>
7776
<tag>
78-
api2pdf-1.0.13
77+
api2pdf-2.0.0
7978
</tag>
8079
</scm>
8180
<properties>

0 commit comments

Comments
 (0)