From 659292a3f12bb111481008a4bd596bec9bd81514 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Tue, 10 Dec 2019 14:39:15 +0100 Subject: [PATCH] updating documentation for go client v7 --- build/docs/content/02-clients.md | 6 +- build/docs/content/04-html.md | 121 +++++---- build/docs/content/05-url.md | 28 +-- build/docs/content/06-markdown.md | 18 +- build/docs/content/07-office.md | 35 ++- build/docs/content/08-merge.md | 18 +- build/docs/content/09-timeout.md | 15 +- build/docs/content/10-webhook.md | 49 ++-- build/docs/content/11-result-filename.md | 15 +- docs/index.html | 305 +++++++++++------------ 10 files changed, 298 insertions(+), 312 deletions(-) diff --git a/build/docs/content/02-clients.md b/build/docs/content/02-clients.md index 39bcd0cc..0f4ce7d2 100644 --- a/build/docs/content/02-clients.md +++ b/build/docs/content/02-clients.md @@ -7,9 +7,11 @@ We provide clients in various languages for easing the interactions with the API ## Go client ```bash -$ go get -u github.com/thecodingmachine/gotenberg-go-client/v6 +$ go get -u github.com/thecodingmachine/gotenberg-go-client/v7 ``` +See also the example from the [README](https://github.com/thecodingmachine/gotenberg-go-client/blob/master/README.md). + ## PHP client Unless your project already has a PSR7 `HttpClient`, install `php-http/guzzle6-adapter`: @@ -24,6 +26,8 @@ Then the [PHP client](https://github.com/thecodingmachine/gotenberg-php-client): $ composer require thecodingmachine/gotenberg-php-client ``` +See also the example from the [README](https://github.com/thecodingmachine/gotenberg-php-client/blob/master/README.md). + ## Community clients * [JavaScript/TypeScript client](https://github.com/yumauri/gotenberg-js-client) by [yumauri](https://github.com/yumauri) diff --git a/build/docs/content/04-html.md b/build/docs/content/04-html.md index 00a5fb8c..513fc6f8 100644 --- a/build/docs/content/04-html.md +++ b/build/docs/content/04-html.md @@ -39,14 +39,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -57,7 +56,7 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $dest = 'result.pdf'; $client->store($request, $dest); @@ -120,16 +119,17 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.Header("header.html") - req.Footer("footer.html") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +header, _ := gotenberg.NewDocumentFromPath("header.html", "/path/to/file") +footer, _ := gotenberg.NewDocumentFromPath("footer.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.Header(header) +req.Footer(footer) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -140,9 +140,9 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); -$header = DocumentFactory::makeFromPath('header.html', 'header.html'); -$footer = DocumentFactory::makeFromPath('footer.html', 'footer.html'); +$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); @@ -210,15 +210,17 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.Assets("font.woff", "img.gif", "style.css") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +style, _ := gotenberg.NewDocumentFromPath("style.css", "/path/to/file") +img, _ := gotenberg.NewDocumentFromPath("img.png", "/path/to/file") +font, _ := gotenberg.NewDocumentFromPath("font.woff", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.Assets(style, img, font) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -229,11 +231,11 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $assets = [ - DocumentFactory::makeFromPath('style.css', 'style.css'), - DocumentFactory::makeFromPath('img.png', 'img.png'), - DocumentFactory::makeFromPath('font.woff', 'font.woff'), + 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); @@ -269,17 +271,16 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.PaperSize(gotenberg.A4) - req.Margins(gotenberg.NoMargins) - req.Landscape(true) - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.PaperSize(gotenberg.A4) +req.Margins(gotenberg.NoMargins) +req.Landscape(true) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -291,7 +292,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; use TheCodingMachine\Gotenberg\Request; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); @@ -322,15 +323,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.WaitDelay(5.5) - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.WaitDelay(5.5) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -342,7 +342,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; use TheCodingMachine\Gotenberg\Request; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setWaitDelay(5.5); $dest = 'result.pdf'; @@ -374,15 +374,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.GoogleChromeRpccBufferSize(1048576) - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.GoogleChromeRpccBufferSize(1048576) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -394,7 +393,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; use TheCodingMachine\Gotenberg\Request; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setGoogleChromeRpccBufferSize(1048576); $dest = 'result.pdf'; diff --git a/build/docs/content/05-url.md b/build/docs/content/05-url.md index 16c42b83..fc307445 100644 --- a/build/docs/content/05-url.md +++ b/build/docs/content/05-url.md @@ -31,15 +31,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req := gotenberg.NewURLRequest("https://google.com") - req.Margins(gotenberg.NoMargins) - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +req := gotenberg.NewURLRequest("https://google.com") +req.Margins(gotenberg.NoMargins) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -82,15 +80,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req := gotenberg.NewURLRequest("https://google.com") - req.AddRemoteURLHTTPHeader("Your-Header", "Foo") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +req := gotenberg.NewURLRequest("https://google.com") +req.AddRemoteURLHTTPHeader("Your-Header", "Foo") +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP diff --git a/build/docs/content/06-markdown.md b/build/docs/content/06-markdown.md index 65b71702..5838ea7b 100644 --- a/build/docs/content/06-markdown.md +++ b/build/docs/content/06-markdown.md @@ -42,14 +42,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewMarkdownRequest("index.html", "file.md") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +markdown, _ := gotenberg.NewDocumentFromPath("file.md", "/path/to/file") +req := gotenberg.NewMarkdownRequest(index, markdown) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -60,9 +60,9 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\MarkdownRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $markdowns = [ - DocumentFactory::makeFromPath('file.md', 'file.md'), + DocumentFactory::makeFromPath('file.md', '/path/to/file'), ]; $request = new MarkdownRequest($index, $markdowns); $dest = 'result.pdf'; diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index 70a1e2fa..d9545027 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -41,14 +41,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewOfficeRequest("document.docx", "document2.docx") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +doc, _ := gotenberg.NewDocumentFromPath("document.docx", "/path/to/file") +doc2, _ := gotenberg.NewDocumentFromPath("document2.docx", "/path/to/file") +req := gotenberg.NewOfficeRequest(doc, doc2) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -60,8 +60,8 @@ use TheCodingMachine\Gotenberg\OfficeRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $files = [ - DocumentFactory::makeFromPath('document.docx', 'document.docx'), - DocumentFactory::makeFromPath('document2.docx', 'document2.docx'), + DocumentFactory::makeFromPath('document.docx', '/path/to/file'), + DocumentFactory::makeFromPath('document2.docx', '/path/to/file'), ]; $request = new OfficeRequest($files); $dest = 'result.pdf'; @@ -88,15 +88,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewOfficeRequest("document.docx") - req.Landscape(true) - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +doc, _ := gotenberg.NewDocumentFromPath("document.docx", "/path/to/file") +req := gotenberg.NewOfficeRequest(doc) +req.Landscape(true) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -108,7 +107,7 @@ use TheCodingMachine\Gotenberg\OfficeRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $files = [ - DocumentFactory::makeFromPath('document.docx', 'document.docx'), + DocumentFactory::makeFromPath('document.docx', '/path/to/file'), ]; $request = new OfficeRequest($files); $request->setLandscape(true); diff --git a/build/docs/content/08-merge.md b/build/docs/content/08-merge.md index fc0d50ba..8e693743 100644 --- a/build/docs/content/08-merge.md +++ b/build/docs/content/08-merge.md @@ -27,14 +27,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewMergeRequest("file.pdf", "file2.pdf") - dest := "result.pdf" - c.Store(req, dest) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +pdf, _ := gotenberg.NewDocumentFromPath("file.pdf", "/path/to/file") +pdf2, _ := gotenberg.NewDocumentFromPath("file2.pdf", "/path/to/file") +req := gotenberg.NewMergeRequest(pdf, pdf2) +dest := "result.pdf" +c.Store(req, dest) ``` ### PHP @@ -46,8 +46,8 @@ use TheCodingMachine\Gotenberg\MergeRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $files = [ - DocumentFactory::makeFromPath('file.pdf', 'file.pdf'), - DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'), + DocumentFactory::makeFromPath('file.pdf', '/path/to/file'), + DocumentFactory::makeFromPath('file2.pdf', '/path/to/file'), ]; $request = new MergeRequest($files); $dest = 'result.pdf'; diff --git a/build/docs/content/09-timeout.md b/build/docs/content/09-timeout.md index 7c644cec..c7cbbd70 100644 --- a/build/docs/content/09-timeout.md +++ b/build/docs/content/09-timeout.md @@ -26,14 +26,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.WaitTimeout(2.5) - resp, _ := c.Post(req) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.WaitTimeout(2.5) +resp, _ := c.Post(req) ``` ### PHP @@ -45,7 +44,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; use TheCodingMachine\Gotenberg\Request; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setWaitTimeout(2.5); $dest = 'result.pdf'; diff --git a/build/docs/content/10-webhook.md b/build/docs/content/10-webhook.md index 06c97f24..3d5e69e1 100644 --- a/build/docs/content/10-webhook.md +++ b/build/docs/content/10-webhook.md @@ -24,14 +24,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.WebhookURL("http://myapp.com/webhook/") - resp, _ := c.Post(req) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.WebhookURL("http://myapp.com/webhook/") +resp, _ := c.Post(req) ``` ### PHP @@ -42,7 +41,7 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setWebhookURL('http://myapp.com/webhook/'); $resp = $client->post($request); @@ -72,15 +71,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.WebhookURL("http://myapp.com/webhook/") - req.WebhookURLTimeout(2.5) - resp, _ := c.Post(req) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.WebhookURL("http://myapp.com/webhook/") +req.WebhookURLTimeout(2.5) +resp, _ := c.Post(req) ``` ### PHP @@ -91,7 +89,7 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setWebhookURL('http://myapp.com/webhook/'); $request->setWebhookURLTimeout(2.5); @@ -125,15 +123,14 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.WebhookURL("http://myapp.com/webhook/") - req.AddWebhookURLHTTPHeader("Your-Header", "Foo") - resp, _ := c.Post(req) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.WebhookURL("http://myapp.com/webhook/") +req.AddWebhookURLHTTPHeader("Your-Header", "Foo") +resp, _ := c.Post(req) ``` ### PHP @@ -144,7 +141,7 @@ use TheCodingMachine\Gotenberg\DocumentFactory; use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setWebhookURL('http://myapp.com/webhook/'); $request->addWebhookURLHTTPHeader('Your-Header', 'Foo'); diff --git a/build/docs/content/11-result-filename.md b/build/docs/content/11-result-filename.md index aabb4177..94bc230f 100644 --- a/build/docs/content/11-result-filename.md +++ b/build/docs/content/11-result-filename.md @@ -24,14 +24,13 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v6" +import "github.com/thecodingmachine/gotenberg-go-client/v7" -func main() { - c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewHTMLRequest("index.html") - req.ResultFilename("foo.pdf") - resp, _ := c.Post(req) -} +c := &gotenberg.Client{Hostname: "http://localhost:3000"} +index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file") +req := gotenberg.NewHTMLRequest(index) +req.ResultFilename("foo.pdf") +resp, _ := c.Post(req) ``` ### PHP @@ -43,7 +42,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; use TheCodingMachine\Gotenberg\Request; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); -$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$index = DocumentFactory::makeFromPath('index.html', '/path/to/file'); $request = new HTMLRequest($index); $request->setResultFilename('foo.pdf'); $resp = $client->post($request); diff --git a/docs/index.html b/docs/index.html index 95af3d47..af20018c 100755 --- a/docs/index.html +++ b/docs/index.html @@ -221,9 +221,11 @@ Gotenberg API is available at http://localhost:3 Go client -
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v6
+
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v7
 
+

See also the example from the README.

+

PHP client

@@ -238,6 +240,8 @@ Gotenberg API is available at http://localhost:3
$ composer require thecodingmachine/gotenberg-php-client
 
+

See also the example from the README.

+

Community clients

@@ -453,14 +457,13 @@ which will be converted to PDF.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.Header("header.html")
-    req.Footer("footer.html")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+header, _ := gotenberg.NewDocumentFromPath("header.html", "/path/to/file")
+footer, _ := gotenberg.NewDocumentFromPath("footer.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.Header(header)
+req.Footer(footer)
+dest := "result.pdf"
+c.Store(req, dest)
 

fonts section.

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.Assets("font.woff", "img.gif", "style.css")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+style, _ := gotenberg.NewDocumentFromPath("style.css", "/path/to/file")
+img, _ := gotenberg.NewDocumentFromPath("img.png", "/path/to/file")
+font, _ := gotenberg.NewDocumentFromPath("font.woff", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.Assets(style, img, font)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.PaperSize(gotenberg.A4)
-    req.Margins(gotenberg.NoMargins)
-    req.Landscape(true)
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.PaperSize(gotenberg.A4)
+req.Margins(gotenberg.NoMargins)
+req.Landscape(true)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.WaitDelay(5.5)
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.WaitDelay(5.5)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.GoogleChromeRpccBufferSize(1048576)
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.GoogleChromeRpccBufferSize(1048576)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req := gotenberg.NewURLRequest("https://google.com")
-    req.Margins(gotenberg.NoMargins)
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+req := gotenberg.NewURLRequest("https://google.com")
+req.Margins(gotenberg.NoMargins)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req := gotenberg.NewURLRequest("https://google.com")
-    req.AddRemoteURLHTTPHeader("Your-Header", "Foo")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+req := gotenberg.NewURLRequest("https://google.com")
+req.AddRemoteURLHTTPHeader("Your-Header", "Foo")
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewMarkdownRequest("index.html", "file.md")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+markdown, _ := gotenberg.NewDocumentFromPath("file.md", "/path/to/file")
+req := gotenberg.NewMarkdownRequest(index, markdown)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewOfficeRequest("document.docx", "document2.docx")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+doc, _ := gotenberg.NewDocumentFromPath("document.docx", "/path/to/file")
+doc2, _ := gotenberg.NewDocumentFromPath("document2.docx", "/path/to/file")
+req := gotenberg.NewOfficeRequest(doc, doc2)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewOfficeRequest("document.docx")
-    req.Landscape(true)
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+doc, _ := gotenberg.NewDocumentFromPath("document.docx", "/path/to/file")
+req := gotenberg.NewOfficeRequest(doc)
+req.Landscape(true)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewMergeRequest("file.pdf", "file2.pdf")
-    dest := "result.pdf"
-    c.Store(req, dest)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+pdf, _ := gotenberg.NewDocumentFromPath("file.pdf", "/path/to/file")
+pdf2, _ := gotenberg.NewDocumentFromPath("file2.pdf", "/path/to/file")
+req := gotenberg.NewMergeRequest(pdf, pdf2)
+dest := "result.pdf"
+c.Store(req, dest)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.WaitTimeout(2.5)
-    resp, _ := c.Post(req)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.WaitTimeout(2.5)
+resp, _ := c.Post(req)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.WebhookURL("http://myapp.com/webhook/")
-    resp, _ := c.Post(req)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.WebhookURL("http://myapp.com/webhook/")
+resp, _ := c.Post(req)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.WebhookURL("http://myapp.com/webhook/")
-    req.WebhookURLTimeout(2.5)
-    resp, _ := c.Post(req)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.WebhookURL("http://myapp.com/webhook/")
+req.WebhookURLTimeout(2.5)
+resp, _ := c.Post(req)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.WebhookURL("http://myapp.com/webhook/")
-    req.AddWebhookURLHTTPHeader("Your-Header", "Foo")
-    resp, _ := c.Post(req)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.WebhookURL("http://myapp.com/webhook/")
+req.AddWebhookURLHTTPHeader("Your-Header", "Foo")
+resp, _ := c.Post(req)
 

Go

-
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
import "github.com/thecodingmachine/gotenberg-go-client/v7"
 
-func main() {
-    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.ResultFilename("foo.pdf")
-    resp, _ := c.Post(req)
-}
+c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
+req := gotenberg.NewHTMLRequest(index)
+req.ResultFilename("foo.pdf")
+resp, _ := c.Post(req)