diff --git a/build/docs/content/15-links.md b/build/docs/content/15-links.md index 442e718f..68a855e8 100644 --- a/build/docs/content/15-links.md +++ b/build/docs/content/15-links.md @@ -9,3 +9,4 @@ title: Links * Follow the progress on the [GitHub repository](https://github.com/thecodingmachine/gotenberg) * Follow [@gulnap](https://twitter.com/gulnap) on Twitter * Thanks to [@mafredri](https://github.com/mafredri) for his help and his wonderful [cdp](https://github.com/mafredri/cdp) library +* OpenAPI documentation for the API can be found [on GitHub](https://github.com/thecodingmachine/gotenberg/blob/master/docs/openapi.yaml) diff --git a/docs/index.html b/docs/index.html index 606e9133..c4cc6920 100755 --- a/docs/index.html +++ b/docs/index.html @@ -167,14 +167,14 @@ $ make publish GOTENBERG_USER_GID=You may also add it in your Docker Compose stack:

-
version: '3'
+
version: '3'
 
-services:
+services:
 
   # your other services
 
-  gotenberg:
-    image: thecodingmachine/gotenberg:6
+  gotenberg:
+    image: thecodingmachine/gotenberg:6
 
@@ -481,15 +481,15 @@ which will be converted to PDF.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$header = DocumentFactory::makeFromPath('header.html', '/path/to/file');
-$footer = DocumentFactory::makeFromPath('footer.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setHeader($header);
-$request->setFooter($footer);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$header = DocumentFactory::makeFromPath('header.html', '/path/to/file');
+$footer = DocumentFactory::makeFromPath('footer.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setHeader($header);
+$request->setFooter($footer);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

fonts section.

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$assets = [
-    DocumentFactory::makeFromPath('style.css', '/path/to/file'),
-    DocumentFactory::makeFromPath('img.png', '/path/to/file'),
-    DocumentFactory::makeFromPath('font.woff', '/path/to/file'),
-];
-$request = new HTMLRequest($index);
-$request->setAssets($assets);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$assets = [
+    DocumentFactory::makeFromPath('style.css', '/path/to/file'),
+    DocumentFactory::makeFromPath('img.png', '/path/to/file'),
+    DocumentFactory::makeFromPath('font.woff', '/path/to/file'),
+];
+$request = new HTMLRequest($index);
+$request->setAssets($assets);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setPaperSize(Request::A4);
-$request->setMargins(Request::NO_MARGINS);
-$request->setLandscape(true);
-$request->setScale(0.75);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setPaperSize(Request::A4);
+$request->setMargins(Request::NO_MARGINS);
+$request->setLandscape(true);
+$request->setScale(0.75);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setPageRanges('1-3,5');
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setPageRanges('1-3,5');
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setWaitDelay(5.5);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setWaitDelay(5.5);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setGoogleChromeRpccBufferSize(1048576);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setGoogleChromeRpccBufferSize(1048576);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -976,14 +976,14 @@ the resulting PDF will be blank. Make sure to rename your service to avoid this PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\URLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\URLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$request = new URLRequest('https://google.com');
-$request->setMargins(Request::NO_MARGINS);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$request = new URLRequest('https://google.com');
+$request->setMargins(Request::NO_MARGINS);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\URLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\URLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$request = new URLRequest('https://google.com');
-$request->addRemoteURLHTTPHeader('Your-Header', 'Foo')
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$request = new URLRequest('https://google.com');
+$request->addRemoteURLHTTPHeader('Your-Header', 'Foo')
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -1105,18 +1105,18 @@ in the file index.html. This function will convert a given markdown PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\MarkdownRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\MarkdownRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$markdowns = [
-    DocumentFactory::makeFromPath('file.md', '/path/to/file'),
-];
-$request = new MarkdownRequest($index, $markdowns);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$markdowns = [
+    DocumentFactory::makeFromPath('file.md', '/path/to/file'),
+];
+$request = new MarkdownRequest($index, $markdowns);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -1186,18 +1186,18 @@ $client->store($request, $dest); PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\OfficeRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\OfficeRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
-    DocumentFactory::makeFromPath('document2.docx', '/path/to/file'),
-];
-$request = new OfficeRequest($files);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
+    DocumentFactory::makeFromPath('document2.docx', '/path/to/file'),
+];
+$request = new OfficeRequest($files);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\OfficeRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\OfficeRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
-];
-$request = new OfficeRequest($files);
-$request->setLandscape(true);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
+];
+$request = new OfficeRequest($files);
+$request->setLandscape(true);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\OfficeRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\OfficeRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
-];
-$request = new OfficeRequest($files);
-$request->setPageRanges('1-3');
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
+];
+$request = new OfficeRequest($files);
+$request->setPageRanges('1-3');
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -1361,18 +1361,18 @@ will merge them and return the resulting PDF file.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\MergeRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\MergeRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('file.pdf', '/path/to/file'),
-    DocumentFactory::makeFromPath('file2.pdf', '/path/to/file'),
-];
-$request = new MergeRequest($files);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('file.pdf', '/path/to/file'),
+    DocumentFactory::makeFromPath('file2.pdf', '/path/to/file'),
+];
+$request = new MergeRequest($files);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -1424,17 +1424,17 @@ If unsucessful, it returns a 504 HTTP code.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setWaitTimeout(2.5);
-$dest = 'result.pdf';
-$client->store($request, $dest);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setWaitTimeout(2.5);
+$dest = 'result.pdf';
+$client->store($request, $dest);
 
@@ -1482,15 +1482,15 @@ to given URL.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setWebhookURL('http://myapp.com/webhook/');
-$resp = $client->post($request);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$resp = $client->post($request);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setWebhookURL('http://myapp.com/webhook/');
-$request->setWebhookURLTimeout(2.5);
-$resp = $client->post($request);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$request->setWebhookURLTimeout(2.5);
+$resp = $client->post($request);
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setWebhookURL('http://myapp.com/webhook/');
-$request->addWebhookURLHTTPHeader('Your-Header', 'Foo');
-$resp = $client->post($request);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$request->addWebhookURLHTTPHeader('Your-Header', 'Foo');
+$resp = $client->post($request);
 
@@ -1655,16 +1655,16 @@ Otherwise a random filename is used.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
 
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
-$request = new HTMLRequest($index);
-$request->setResultFilename('foo.pdf');
-$resp = $client->post($request);
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
+$request = new HTMLRequest($index);
+$request->setResultFilename('foo.pdf');
+$resp = $client->post($request);
 
@@ -1713,14 +1713,14 @@ if the API is under heavy load.

For instance, using the following Docker Compose file:

-
version: '3'
+
version: '3'
 
-services:
+services:
 
   # your other services
 
-  gotenberg:
-    image: thecodingmachine/gotenberg:6
+  gotenberg:
+    image: thecodingmachine/gotenberg:6
 

You may now launch your services using:

@@ -1778,7 +1778,8 @@ restart your Gotenberg instances from time to time to ensure a nominal behaviour diff --git a/docs/openapi.yaml b/docs/openapi.yaml new file mode 100644 index 00000000..7545a445 --- /dev/null +++ b/docs/openapi.yaml @@ -0,0 +1,558 @@ +openapi: 3.0.0 +info: + title: Gotenberg + version: 6.3.1 + license: + name: MIT + url: 'https://github.com/thecodingmachine/gotenberg/blob/master/LICENSE' + contact: + url: 'https://github.com/thecodingmachine/gotenberg' + description: >- + A Docker-powered stateless API for converting HTML, Markdown and Office + documents to PDF. +servers: + - url: 'http://localhost:3000' + description: Local server with the default Docker image and port +paths: + /convert/html: + post: + summary: Convert a given HTML file to PDF + description: >- + Send an HTML file called `index.html` as a multipart form request, and + get the resulting PDF file. You can optionally include `header.html` and + `footer.html` files as part of the request as well. + + + An example `index.html` file can be as follows: + + ```html + + + + + + + My PDF + + +

Hello world!

+ + + + ``` + + + You may also add a header and/or a footer in the resulting PDF by + sending a file named `header.html` and `footer.html` respectively. Both + the header and the footer files has to be a complete HTML document. An + example `footer.html` can be as follows: + + ```html + + + + + + +

+ of +

+ + + + ``` + + + The following classes will allow you to inject printing values in your + document: + + - `date`: Formatted print date. + + - `title`: Document title. + + - `pageNumber`: Current page number. + + - `totalPage`: Total pages in the document. + + + There are some limitations with header and footer files: + + - JavaScript is not executed. + + - External resources are not loaded. + + - The CSS properties are independant of the ones used in the + `index.html` file. + + - `footer.html` CSS properties override the ones from `header.html`. + + - Only fonts installed in the Docker image are loaded (see the fonts + section) + + - Images only work using a `base64` encoded source, e.g. ` + + + My PDF + + + {{ toHTML .DirPath "file.md" }} + + + + ``` + + + Whereas your `file.md` file in the same level would be like: + + ```md + + # Title + + Content + + ``` + + + The API will convert the markdown to HTML and embed it into your + `index.html` file, then render the resulting page. You can include your + own styling and more in your HTML file. + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/MarkdownConvertRequestBody' + description: >- + The request body must have an `index.html` file in the `files` array, + as well as all the referred markdown resources on the same level as + the `index.html` file. + responses: + '200': + $ref: '#/components/responses/SuccessfulPDF' + /convert/office: + post: + summary: Convert an Office document to PDF + description: >- + Send one or more Office documents and get the resulting PDF file by + merging all the files. The following file extensions are accepted: + + - `.txt` + + - `.rtf` + + - `.fodt` + + - `.doc` + + - `.docx` + + - `.odt` + + - `.xls` + + - `.xlsx` + + - `.ods` + + - `.ppt` + + - `.pptx` + + - `.odp` + + + All files will be merged into a single PDF. + + > **Attention:** The files will be merged alphabetically for the + resulting PDF. + + + You may also specify the page ranges to convert from the incoming Office + documents. The expected format is the same as the one from the print + options of LibreOffice, e.g. `1-1` or `1-4`. + + + > **Attention:** if more than one document, the page ranges will be + applied for each document. + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/OfficeConvertRequestBody' + description: >- + The request body must have an `index.html` file in the `files` array, + as well as all the referred markdown resources on the same level as + the `index.html` file. + responses: + '200': + $ref: '#/components/responses/SuccessfulPDF' + content: + application/json: + schema: + type: object + properties: {} + /convert/merge: + post: + summary: Merge multiple PDFs into a single PDF + description: >- + You can send multiple PDF files to this endpoint, the API will merge + them into a single PDF and return the resulting PDF file. + + + > **Attention:** The PDF files will be merged alphabetically. + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + files: + type: array + description: >- + List of HTML files to be converted to PDF. An `index.html` + file is required, and any other resources that are + referenced through the HTML file must be included as well. + All the referenced files must be on the same level as the + `index.html` file. + items: + type: string + format: binary + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with + the given filename. Otherwise a random filename is used. + required: + - files + description: >- + The request body must have an `index.html` file in the `files` array, + as well as all the referred markdown resources on the same level as + the `index.html` file. + responses: + '200': + $ref: '#/components/responses/SuccessfulPDF' + /ping: + get: + summary: Your GET endpoint + tags: [] + responses: + '200': + description: The API is working fine. + operationId: '' + description: >- + A simple endpoint to use as a healthcheck for the API availability with + a simple request. +components: + schemas: + HTMLConvertRequestBody: + title: HTML Conversion Request Body + type: object + properties: + files: + type: array + description: >- + List of HTML files to be converted to PDF. An `index.html` file is + required, and any other resources that are referenced through the + HTML file must be included as well. All the referenced files must be + on the same level as the `index.html` file. + items: + type: string + format: binary + marginTop: + type: number + example: 0 + default: 1 + description: Top margin for the page in inches. + marginBottom: + type: number + example: 0 + default: 1 + description: Bottom margin for the page in inches. + marginLeft: + type: number + example: 0 + default: 1 + description: Left margin for the page in inches. + marginRight: + type: number + example: 0 + default: 1 + description: Right margin for the page in inches. + paperWidth: + type: number + example: 8.27 + description: >- + Paper width to be used while rendering the PDF. The default page + size is A4. + paperHeight: + type: number + example: 11.69 + description: >- + Paper height to be used while rendering the PDF. The default page + size is A4. + landscape: + type: boolean + example: true + default: false + description: >- + The default orientation for rendering the page is "portrait" mode. + By sending "landscape" parameter, you can ask the output to be + landscape. + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with the + given filename. Otherwise a random filename is used. + required: + - files + MarkdownConvertRequestBody: + title: Markdown Conversion Request Body + type: object + properties: + files: + type: array + description: >- + List of HTML files to be converted to PDF. An `index.html` file is + required, and any other resources that are referenced through the + HTML file must be included as well. All the referenced files must be + on the same level as the `index.html` file. + items: + type: string + format: binary + marginTop: + type: number + example: 0 + default: 1 + description: Top margin for the page in inches. + marginBottom: + type: number + example: 0 + default: 1 + description: Bottom margin for the page in inches. + marginLeft: + type: number + example: 0 + default: 1 + description: Left margin for the page in inches. + marginRight: + type: number + example: 0 + default: 1 + description: Right margin for the page in inches. + paperWidth: + type: number + example: 8.27 + description: >- + Paper width to be used while rendering the PDF. The default page + size is A4. + paperHeight: + type: number + example: 11.69 + description: >- + Paper height to be used while rendering the PDF. The default page + size is A4. + landscape: + type: boolean + example: true + default: false + description: >- + The default orientation for rendering the page is "portrait" mode. + By sending "landscape" parameter, you can ask the output to be + landscape. + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with the + given filename. Otherwise a random filename is used. + required: + - files + URLConvertRequestBody: + title: URL Conversion Request Body + type: object + properties: + remoteURL: + type: string + example: 'https://google.com' + marginTop: + type: number + example: 0 + default: 1 + description: Top margin for the page in inches. + marginBottom: + type: number + example: 0 + default: 1 + description: Bottom margin for the page in inches. + marginLeft: + type: number + example: 0 + default: 1 + description: Left margin for the page in inches. + marginRight: + type: number + example: 0 + default: 1 + description: Right margin for the page in inches. + paperWidth: + type: number + example: 8.27 + description: >- + Paper width to be used while rendering the PDF. The default page + size is A4. + paperHeight: + type: number + example: 11.69 + description: >- + Paper height to be used while rendering the PDF. The default page + size is A4. + landscape: + type: boolean + example: true + default: false + description: >- + The default orientation for rendering the page is "portrait" mode. + By sending "landscape" parameter, you can ask the output to be + landscape. + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with the + given filename. Otherwise a random filename is used. + required: + - remoteURL + OfficeConvertRequestBody: + title: Office Conversion Request Body + type: object + properties: + files: + type: array + description: >- + List of HTML files to be converted to PDF. An `index.html` file is + required, and any other resources that are referenced through the + HTML file must be included as well. All the referenced files must be + on the same level as the `index.html` file. + items: + type: string + format: binary + pageRanges: + type: string + example: 1-3 + description: >- + The page ranges to be converted to PDF for the incoming Office + documents. **If there are multiple files sent to the API, this page + range will apply to all of the documents**. + landscape: + type: boolean + example: true + default: false + description: >- + The default orientation for rendering the page is "portrait" mode. + By sending "landscape" parameter, you can ask the output to be + landscape. + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with the + given filename. Otherwise a random filename is used. + required: + - files + MergeFilesRequestBody: + title: Merge Files Request Body + type: object + properties: + files: + type: array + description: >- + List of HTML files to be converted to PDF. An `index.html` file is + required, and any other resources that are referenced through the + HTML file must be included as well. All the referenced files must be + on the same level as the `index.html` file. + items: + type: string + format: binary + resultFilename: + type: string + example: output.pdf + description: >- + If provided, the API will return the resulting PDF file with the + given filename. Otherwise a random filename is used. + required: + - files + securitySchemes: {} + responses: + SuccessfulPDF: + description: Resulting PDF file from the conversion. + content: + application/pdf: + schema: + type: string + format: binary