From 659292a3f12bb111481008a4bd596bec9bd81514 Mon Sep 17 00:00:00 2001
From: Julien Neuhart See also the example from the README. See also the example from the README.$ go get -u github.com/thecodingmachine/gotenberg-go-client/v6
+
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v7
+PHP client
@@ -238,6 +240,8 @@ Gotenberg API is available at http://localhost:3
$ composer require thecodingmachine/gotenberg-php-client
+Community clients
@@ -453,14 +457,13 @@ which will be converted to PDF.
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)@@ -472,7 +475,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); @@ -542,16 +545,17 @@ Respectively, a file named
-header.htmlandfooter.htmlGoimport "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)@@ -563,9 +567,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); @@ -637,15 +641,17 @@ see to the 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)@@ -657,11 +663,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); @@ -703,17 +709,16 @@ $client->store($request, $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)@@ -726,7 +731,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); @@ -763,15 +768,14 @@ a lot on JavaScript for rendering. 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)@@ -784,7 +788,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'; @@ -822,15 +826,14 @@ The hard limit is 100 MB and is defined by Google Chrome itself. 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)@@ -843,7 +846,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'; @@ -891,15 +894,13 @@ If not, some of the content of the page might be hidden. 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)@@ -949,15 +950,13 @@ canonical key for
-accept-encodingisAccept-Encoding.< Goimport "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)@@ -1023,14 +1022,14 @@ in the file
-index.html. This function will convert a given markdown Goimport "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)@@ -1042,9 +1041,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'; @@ -1104,14 +1103,14 @@ $client->store($request, $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)@@ -1124,8 +1123,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'; @@ -1156,15 +1155,14 @@ $client->store($request, $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)@@ -1177,7 +1175,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); @@ -1222,14 +1220,14 @@ will merge them and return the resulting PDF file. 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)@@ -1242,8 +1240,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'; @@ -1286,14 +1284,13 @@ If unsucessful, it returns a
-504HTTP code. Goimport "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)@@ -1306,7 +1303,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'; @@ -1345,14 +1342,13 @@ to given URL. 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)@@ -1364,7 +1360,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); @@ -1400,15 +1396,14 @@ $resp = $client->post($request); 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)@@ -1420,7 +1415,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); @@ -1460,15 +1455,14 @@ canonical key for
-accept-encodingisAccept-Encoding.< Goimport "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)@@ -1480,7 +1474,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'); @@ -1521,14 +1515,13 @@ Otherwise a random filename is used. 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)@@ -1541,7 +1534,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);