diff --git a/README.md b/README.md
index 5927a098..98362773 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ At TheCodingMachine, we build a lot of web applications (intranets, extranets an
Open a terminal and run the following command:
```bash
-$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:3
+$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:4
```
The API is now available on your host at `http://localhost:3000`.
@@ -33,7 +33,7 @@ to learn how to interact with it!
## Badges
-[](https://microbadger.com/images/thecodingmachine/gotenberg:3)
+[](https://microbadger.com/images/thecodingmachine/gotenberg:4)
[](https://travis-ci.org/thecodingmachine/gotenberg)
[](https://godoc.org/github.com/thecodingmachine/gotenberg)
[](https://goreportcard.com/report/thecodingmachine/gotenberg)
diff --git a/build/base/Dockerfile b/build/base/Dockerfile
index 4d11b724..202b1b3b 100644
--- a/build/base/Dockerfile
+++ b/build/base/Dockerfile
@@ -10,7 +10,7 @@ FROM debian:9.5-slim
RUN echo "deb http://httpredir.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list &&\
apt-get update &&\
- apt-get install -y curl wget python3-pip
+ apt-get install -y curl wget python3-pip ttf-mscorefonts-installer
# |--------------------------------------------------------------------------
# | PM2
@@ -66,4 +66,39 @@ RUN pip3 install unoconv &&\
# | https://github.com/thecodingmachine/gotenberg/issues/29
# |
-RUN apt-get -y install pdftk
\ No newline at end of file
+RUN apt-get -y install pdftk
+
+# |--------------------------------------------------------------------------
+# | Fonts
+# |--------------------------------------------------------------------------
+# |
+# | Installs a handful of fonts.
+# | Note: ttf-mscorefonts-installer are installed on top of this Dockerfile.
+# |
+
+# Credits:
+# https://github.com/arachnys/athenapdf/blob/master/cli/Dockerfile
+# https://help.accusoft.com/PrizmDoc/v12.1/HTML/Installing_Asian_Fonts_on_Ubuntu_and_Debian.html
+RUN apt-get install -y \
+ culmus \
+ fonts-beng \
+ fonts-hosny-amiri \
+ fonts-lklug-sinhala \
+ fonts-lohit-guru \
+ fonts-lohit-knda \
+ fonts-samyak-gujr \
+ fonts-samyak-mlym \
+ fonts-samyak-taml \
+ fonts-sarai \
+ fonts-sil-abyssinica \
+ fonts-sil-padauk \
+ fonts-telu \
+ fonts-thai-tlwg \
+ ttf-liberation \
+ ttf-wqy-zenhei \
+ fonts-arphic-uming \
+ fonts-ipafont-mincho \
+ fonts-ipafont-gothic \
+ fonts-unfonts-core
+
+COPY build/base/fonts.conf /etc/fonts/conf.d/100-gotenberg.conf
diff --git a/build/base/fonts.conf b/build/base/fonts.conf
new file mode 100644
index 00000000..344ccbef
--- /dev/null
+++ b/build/base/fonts.conf
@@ -0,0 +1,29 @@
+
+
+
You may start it with:
-$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:3 +$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:4@@ -119,7 +127,7 @@ # your others services gotenberg: - image: thecodingmachine/gotenberg:3 + image: thecodingmachine/gotenberg:4
@@ -354,7 +362,7 @@ are on the same level as theindex.htmlfile.If you want to install fonts directly in the Gotenberg Docker image, -see to the fonts section.
+see to the fonts section.@@ -380,11 +388,7 @@ see to the fonts section. func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} req, _ := gotenberg.NewHTMLRequest("index.html") - req.SetAssets([]string{ - "font.woff", - "img.gif", - "style.css", - }) + req.SetAssets("font.woff", "img.gif", "style.css") dest := "result.pdf" c.Store(req, dest) } @@ -407,8 +411,8 @@ $assets = [ ]; $request = new HTMLRequest($index); $request->setAssets($assets); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$client->store($request, $dest);
@@ -474,8 +478,74 @@ $request = new HTMLRequest($index); $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); $request->setLandscape(true); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$client->store($request, $dest); + + + + +
+@@ -531,7 +601,7 @@ in the fileURL
+Gotenberg provides the endpoint
+ +/convert/urlfor remote URL conversions.It accepts
+ +POSTrequests with amultipart/form-dataContent-Type.Basic
+ +This endpoint does not accept an
+ +index.htmlfile nor assets files but a form field +namedremoteURLinstead. Otherwise, URL conversions work the same as HTML conversions.++ +Attention: when converting a website to PDF, you should remove all margins. +If not, some of the content of the page might be hidden.
+cURL
+ +$ curl --request POST \ + --url http://localhost:3000/convert/url \ + --header 'Content-Type: multipart/form-data' \ + --form remoteURL=https://google.com + --form marginTop=0 \ + --form marginBottom=0 \ + --form marginLeft=0 \ + --form marginRight=0 \ + -o result.pdf ++ +Go
+ +import "github.com/thecodingmachine/gotenberg/pkg" + +func main() { + c := &gotenberg.Client{Hostname: "http://localhost:3000"} + req := gotenberg.NewURLRequest("https://google.com") + req.SetMargins(gotenberg.NoMargins) + dest := "result.pdf" + c.Store(req, dest) +} ++ +PHP
+ +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"; +$filename = $client->store($request, $dest);index.html. This function will convert a given markdown func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewMarkdownRequest("index.html", []string{"file.md"}) + req, _ := gotenberg.NewMarkdownRequest("index.html", "file.md") dest := "result.pdf" c.Store(req, dest) } @@ -551,8 +621,8 @@ $markdowns = [ DocumentFactory::makeFromPath('file.md', 'file.md'), ]; $request = new MarkdownRequest($index, $markdowns); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$filename = $client->store($request, $dest); @@ -613,7 +683,7 @@ See the scalability section to find how to mitigate t func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewOfficeRequest([]string{"document.docx", "document2.docx"}) + req, _ := gotenberg.NewOfficeRequest("document.docx", "document2.docx") dest := "result.pdf" c.Store(req, dest) } @@ -633,8 +703,8 @@ $files = [ DocumentFactory::makeFromPath('document2.docx', 'document2.docx'), ]; $request = new OfficeRequest($files); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$filename = $client->store($request, $dest);@@ -665,7 +735,7 @@ $filename = $client->store($request, $dirPath); func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewOfficeRequest([]string{"document.docx"}) + req, _ := gotenberg.NewOfficeRequest("document.docx") req.SetLandscape(true) dest := "result.pdf" c.Store(req, dest) @@ -686,23 +756,10 @@ $files = [ ]; $request = new OfficeRequest($files); $request->setLandscape(true); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$filename = $client->store($request, $dest); -
- -Fonts
- -By default, only
- -ttf-mscorefontsfonts are installed.If you wish to use more fonts, you will have to create your own image:
- -FROM thecodingmachine/gotenberg:3 - -RUN apt-get -y install yourfonts --@@ -740,7 +797,7 @@ will merge them and return the resulting PDF file. func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} - req, _ := gotenberg.NewMergeRequest([]string{"file.pdf", "file2.pdf"}) + req, _ := gotenberg.NewMergeRequest("file.pdf", "file2.pdf") dest := "result.pdf" c.Store(req, dest) } @@ -760,8 +817,8 @@ $files = [ DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'), ]; $request = new MergeRequest($files); -$dirPath = "/foo"; -$filename = $client->store($request, $dirPath); +$dest = "result.pdf"; +$filename = $client->store($request, $dest);@@ -839,7 +896,7 @@ $resp = $client->post($request); # your others services gotenberg: - image: thecodingmachine/gotenberg:3 + image: thecodingmachine/gotenberg:4You may now launch your services using:
@@ -868,6 +925,21 @@ a simpleGETrequest. +++Fonts
+By default, a handful of fonts are installed. Asian characters are also supported out of the box.
+ +If you wish to use more fonts, you will have to create your own image:
+ +FROM thecodingmachine/gotenberg:4 + +RUN apt-get -y install yourfonts ++ +