@@ -11,21 +11,12 @@ Api2Pdf.com is a powerful REST API for instantly generating PDF and Office docum
1111
1212## <a name =" installation " ></a >Installation
1313
14- Add this repository to your Composer file (you can also find us on [ Packagist ] ( https://packagist.org/packages/api2pdf/api2pdf.php ) ) :
14+ Run the following from command line :
1515
1616```
17- "repositories": [
18- {
19- "type": "vcs",
20- "url": "https://github.com/api2pdf/api2pdf.php"
21- }
22- ],
17+ $ composer require api2pdf/api2pdf.php
2318```
2419
25- Run the following from command line:
26-
27- `` $ composer require api2pdf/api2pdf.php:dev-master ``
28-
2920## Usage without Composer
3021
3122Copy the file in the ` src ` directory to a sub-directory in your project, then add the following in the beginning of your PHP file:
@@ -57,60 +48,80 @@ Create an account at [portal.api2pdf.com](https://portal.api2pdf.com/register) t
5748
5849All usage starts by calling the import command and initializing the client by passing your API key as a parameter to the constructor.
5950
60- $apiClient = new Api2Pdf('YOUR-API-KEY')
51+ ``` php
52+ use Api2Pdf\Api2Pdf;
53+
54+ $apiClient = new Api2Pdf('YOUR-API-KEY');
55+ ```
6156
6257Once you initialize the client, you can make calls like so:
6358
64- $result = $apiClient->chromeHtmlToPdf('<p>Hello, World</p>');
65- echo $result->getFile();
59+ ``` php
60+ $result = $apiClient->chromeHtmlToPdf('<p >Hello, World</p >');
61+ echo $result->getFile();
62+ ```
6663
6764### Result Format
6865
6966An ApiResult object is returned from every API call. If a call is unsuccessful then an exception will be thrown with a message containing the result of failure.
7067
7168Additional attributes include the total data usage out, and the cost for the API call, typically very small fractions of a penny.
7269
73- $file = $result->getFile();
74- $cost = $result->getCost();
75- $mbOut = $result->getMbOut();
76- $seconds = $result->getSeconds();
77- $responseId = $result->getResponseId();
70+ ``` php
71+ $file = $result->getFile();
72+ $cost = $result->getCost();
73+ $mbOut = $result->getMbOut();
74+ $seconds = $result->getSeconds();
75+ $responseId = $result->getResponseId();
76+ ```
7877
7978### <a name =" wkhtmltopdf " ></a > wkhtmltopdf
8079
8180** Convert HTML to PDF**
8281
83- $result = $apiClient->wkHtmlToPdf('<p>Hello, World</p>');
82+ ``` php
83+ $result = $apiClient->wkHtmlToPdf('<p >Hello, World</p >');
84+ ```
8485
8586** Convert HTML to PDF (load PDF in browser window and specify a file name)**
8687
87- $result = $apiClient->wkHtmlToPdf('<p>Hello, World</p>', $inline = false, $fileName = "test.pdf");
88+ ``` php
89+ $result = $apiClient->wkHtmlToPdf('<p >Hello, World</p >', $inline = false, $fileName = "test.pdf");
90+ ```
8891
8992** Convert HTML to PDF (use arguments for advanced wkhtmltopdf settings)**
9093[ View full list of wkhtmltopdf options available.] ( https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/ )
9194
92- $options = [
93- "orientation" => "landscape",
94- "pageSize" => "A4"
95- ];
96- $result = $apiClient->wkHtmlToPdf('<p>Hello, World</p>', $options = $options);
95+ ``` php
96+ $options = [
97+ "orientation" => "landscape",
98+ "pageSize" => "A4"
99+ ];
100+ $result = $apiClient->wkHtmlToPdf('<p >Hello, World</p >', $options = $options);
101+ ```
97102
98103** Convert URL to PDF**
99104
100- $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com');
105+ ``` php
106+ $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com');
107+ ```
101108
102109** Convert URL to PDF (load PDF in browser window and specify a file name)**
103110
104- $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com', $inline = false, $fileName = "test.pdf");
111+ ``` php
112+ $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com', $inline = false, $fileName = "test.pdf");
113+ ```
105114
106115** Convert URL to PDF (use arguments for advanced wkhtmltopdf settings)**
107116[ View full list of wkhtmltopdf options available.] ( https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/ )
108117
109- $options = [
110- "orientation" => "landscape",
111- "pageSize" => "A4"
112- ];
113- $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com', $options = $options);
118+ ``` php
119+ $options = [
120+ "orientation" => "landscape",
121+ "pageSize" => "A4"
122+ ];
123+ $result = $apiClient->wkUrlToPdf('http://www.api2pdf.com', $options = $options);
124+ ```
114125
115126
116127---
@@ -119,67 +130,91 @@ Additional attributes include the total data usage out, and the cost for the API
119130
120131** Convert HTML to PDF**
121132
122- $result = $apiClient->chromeHtmlToPdf('<p>Hello, World</p>');
133+ ``` php
134+ $result = $apiClient->chromeHtmlToPdf('<p >Hello, World</p >');
135+ ```
123136
124137** Convert HTML to PDF (load PDF in browser window and specify a file name)**
125138
126- $result = $apiClient->chromeHtmlToPdf('<p>Hello, World</p>', $inline = false, $filename = "test.pdf");
139+ ``` php
140+ $result = $apiClient->chromeHtmlToPdf('<p >Hello, World</p >', $inline = false, $filename = "test.pdf");
141+ ```
127142
128143** Convert HTML to PDF (use arguments for advanced Headless Chrome settings)**
129144[ View full list of Headless Chrome options available.] ( https://www.api2pdf.com/documentation/advanced-options-headless-chrome/ )
130145
131- $options = [
132- "landscape" => true
133- ];
134- $result = $apiClient->chromeHtmlToPdf('<p>Hello, World</p>', $options = $options);
146+ ``` php
147+ $options = [
148+ "landscape" => true
149+ ];
150+ $result = $apiClient->chromeHtmlToPdf('<p >Hello, World</p >', $options = $options);
151+ ```
135152
136153** Convert URL to PDF**
137154
138- $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com');
155+ ``` php
156+ $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com');
157+ ```
139158
140159** Convert URL to PDF (load PDF in browser window and specify a file name)**
141160
142- $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com', $inline = false, $filename = "test.pdf");
161+ ``` php
162+ $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com', $inline = false, $filename = "test.pdf");
163+ ```
143164
144165** Convert URL to PDF (use arguments for advanced Headless Chrome settings)**
145166[ View full list of Headless Chrome options available.] ( https://www.api2pdf.com/documentation/advanced-options-headless-chrome/ )
146167
147- $options = [
148- "landscape" => true
149- ];
150- $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com', $options = $options);
168+ ``` php
169+ $options = [
170+ "landscape" => true
171+ ];
172+ $result = $apiClient->chromeUrlToPdf('http://www.api2pdf.com', $options = $options);
173+ ```
151174
152175** Convert HTML to Image**
153176
154- $result = $apiClient->chromeHtmlToImage('<p>Hello, World</p>');
177+ ``` php
178+ $result = $apiClient->chromeHtmlToImage('<p >Hello, World</p >');
179+ ```
155180
156181** Convert HTML to Image (load image in browser window and specify a file name)**
157182
158- $result = $apiClient->chromeHtmlToImage('<p>Hello, World</p>', $inline = false, $filename = "test.jpg");
183+ ``` php
184+ $result = $apiClient->chromeHtmlToImage('<p >Hello, World</p >', $inline = false, $filename = "test.jpg");
185+ ```
159186
160187** Convert HTML to Image (use arguments for advanced Headless Chrome settings)**
161188[ View full list of Headless Chrome options available.] ( https://www.api2pdf.com/documentation/advanced-options-headless-chrome/ )
162189
163- $options = [
164- "fullPage" => true
165- ];
166- $result = $apiClient->chromeHtmlToImage('<p>Hello, World</p>', $options = $options);
190+ ``` php
191+ $options = [
192+ "fullPage" => true
193+ ];
194+ $result = $apiClient->chromeHtmlToImage('<p >Hello, World</p >', $options = $options);
195+ ```
167196
168197** Convert URL to Image**
169198
170- $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com');
199+ ``` php
200+ $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com');
201+ ```
171202
172203** Convert URL to Image (load image in browser window and specify a file name)**
173204
174- $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com', $inline = false, $filename = "test.jpg");
205+ ``` php
206+ $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com', $inline = false, $filename = "test.jpg");
207+ ```
175208
176209** Convert URL to Image (use arguments for advanced Headless Chrome settings)**
177210[ View full list of Headless Chrome options available.] ( https://www.api2pdf.com/documentation/advanced-options-headless-chrome/ )
178211
179- $options = [
180- "landscape" => true
181- ];
182- $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com', $options = $options);
212+ ``` php
213+ $options = [
214+ "landscape" => true
215+ ];
216+ $result = $apiClient->chromeUrlToImage('http://www.api2pdf.com', $options = $options);
217+ ```
183218
184219---
185220
@@ -191,23 +226,33 @@ You must provide a url to the file. Our engine will consume the file at that URL
191226
192227** Convert Microsoft Office Document or Image to PDF**
193228
194- $result = $apiClient->libreOfficeAnyToPdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx');
229+ ``` php
230+ $result = $apiClient->libreOfficeAnyToPdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx');
231+ ```
195232
196233** Thumbnail or Image Preview of a PDF or Office Document or Email file**
197234
198- $result = $apiClient->libreOfficeThumbnail('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx');
235+ ``` php
236+ $result = $apiClient->libreOfficeThumbnail('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx');
237+ ```
199238
200239** Convert HTML to Microsoft Word or Docx**
201240
202- $result = $apiClient->libreOfficeHtmlToDocx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html');
241+ ``` php
242+ $result = $apiClient->libreOfficeHtmlToDocx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html');
243+ ```
203244
204245** Convert HTML to Microsoft Excel or Xlsx**
205246
206- $result = $apiClient->libreOfficeHtmlToXlsx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html');
247+ ``` php
248+ $result = $apiClient->libreOfficeHtmlToXlsx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html');
249+ ```
207250
208251** Convert PDF to HTML**
209252
210- $result = $apiClient->libreOfficePdfToHtml('http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf');
253+ ``` php
254+ $result = $apiClient->libreOfficePdfToHtml('http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf');
255+ ```
211256---
212257
213258## <a name =" merge " ></a >PdfSharp - Merge / Concatenate Two or More PDFs, Add bookmarks to pdfs, add passwords to pdfs
@@ -216,23 +261,29 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine wi
216261
217262** Merge PDFs from list of URLs to existing PDFs**
218263
219- $linksToPdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'];
220- $mergeResult = $apiClient->pdfsharpMerge($linksToPdfs)
264+ ``` php
265+ $linksToPdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'];
266+ $mergeResult = $apiClient->pdfsharpMerge($linksToPdfs);
267+ ```
221268
222269** Add bookmarks to existing PDF**
223270
224- $linkToPdf = 'https://LINK-TO-PDF';
225- $bookmarks = [
226- [ "Page" => 0, "Title" => "Introduction" ],
227- [ "Page" => 1, "Title" => "Second page" ]
228- ];
229- $bookmarkResult = $apiClient->pdfsharpAddBookmarks($linkToPdf, $bookmarks)
271+ ``` php
272+ $linkToPdf = 'https://LINK-TO-PDF';
273+ $bookmarks = [
274+ [ "Page" => 0, "Title" => "Introduction" ],
275+ [ "Page" => 1, "Title" => "Second page" ]
276+ ];
277+ $bookmarkResult = $apiClient->pdfsharpAddBookmarks($linkToPdf, $bookmarks);
278+ ```
230279
231280** Add password to existing PDF**
232281
233- $linkToPdf = 'https://LINK-TO-PDF';
234- $userpassword = 'hello';
235- $bookmarkResult = $apiClient->pdfsharpAddPassword($linkToPdf, $userpassword)
282+ ``` php
283+ $linkToPdf = 'https://LINK-TO-PDF';
284+ $userpassword = 'hello';
285+ $bookmarkResult = $apiClient->pdfsharpAddPassword($linkToPdf, $userpassword);
286+ ```
236287
237288---
238289
@@ -242,9 +293,9 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine wi
242293
243294By default, Api2Pdf will delete your generated file 24 hours after it has been generated. For those with high security needs, you may want to delete your file on command. You can do so by making an DELETE api call with the ` responseId ` attribute that was returned on the original JSON payload.
244295
245- $result = $apiClient->chromeHtmlToPdf("<p>Hello World</p>");
246- $responseId = $result->getResponseId( );
247- //delete pdf
248- $apiClient->utilityDelete($responseId);
249-
250-
296+ ``` php
297+ $result = $apiClient->chromeHtmlToPdf("< p >Hello World</ p >" );
298+ $responseId = $result->getResponseId();
299+ //delete pdf
300+ $apiClient->utilityDelete($responseId);
301+ ```
0 commit comments