From 70dfea5876f29329789d1a097460dc3867a54136 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 4 Oct 2019 17:49:26 +0200 Subject: [PATCH 1/6] adding pageRanges formField --- internal/app/xhttp/option.go | 10 +++++++ internal/app/xhttp/pkg/resource/arg.go | 4 +++ internal/pkg/printer/chrome.go | 39 ++++++++++++++++++-------- internal/pkg/printer/office.go | 27 +++++++++++++++--- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/internal/app/xhttp/option.go b/internal/app/xhttp/option.go index d79841e8..a40d4ea4 100644 --- a/internal/app/xhttp/option.go +++ b/internal/app/xhttp/option.go @@ -48,6 +48,10 @@ func chromePrinterOptions(r resource.Resource, config conf.Config) (printer.Chro if err != nil { return printer.ChromePrinterOptions{}, err } + pageRanges, err := r.StringArg(resource.PageRangesArgKey, "") + if err != nil { + return printer.ChromePrinterOptions{}, err + } return printer.ChromePrinterOptions{ WaitTimeout: waitTimeout, WaitDelay: waitDelay, @@ -60,6 +64,7 @@ func chromePrinterOptions(r resource.Resource, config conf.Config) (printer.Chro MarginLeft: marginLeft, MarginRight: marginRight, Landscape: landscape, + PageRanges: pageRanges, }, nil } opts, err := resolver() @@ -80,9 +85,14 @@ func officePrinterOptions(r resource.Resource, config conf.Config) (printer.Offi if err != nil { return printer.OfficePrinterOptions{}, err } + pageRanges, err := r.StringArg(resource.PageRangesArgKey, "") + if err != nil { + return printer.OfficePrinterOptions{}, err + } return printer.OfficePrinterOptions{ WaitTimeout: waitTimeout, Landscape: landscape, + PageRanges: pageRanges, }, nil } opts, err := resolver() diff --git a/internal/app/xhttp/pkg/resource/arg.go b/internal/app/xhttp/pkg/resource/arg.go index 35c7800b..3372da46 100644 --- a/internal/app/xhttp/pkg/resource/arg.go +++ b/internal/app/xhttp/pkg/resource/arg.go @@ -51,6 +51,9 @@ const ( // LandscapeArgKey is the key // of the argument "landscape". LandscapeArgKey ArgKey = "landscape" + // PageRangesArgKey is the key + // of the argument "pageRanges". + PageRangesArgKey ArgKey = "pageRanges" ) /* @@ -73,6 +76,7 @@ func ArgKeys() []ArgKey { MarginLeftArgKey, MarginRightArgKey, LandscapeArgKey, + PageRangesArgKey, } } diff --git a/internal/pkg/printer/chrome.go b/internal/pkg/printer/chrome.go index aff21e75..f7cca718 100644 --- a/internal/pkg/printer/chrome.go +++ b/internal/pkg/printer/chrome.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io/ioutil" + "strings" "time" "github.com/mafredri/cdp" @@ -40,6 +41,7 @@ type ChromePrinterOptions struct { MarginLeft float64 MarginRight float64 Landscape bool + PageRanges string } // DefaultChromePrinterOptions returns the default @@ -58,6 +60,7 @@ func DefaultChromePrinterOptions(config conf.Config) ChromePrinterOptions { MarginLeft: 1.0, MarginRight: 1.0, Landscape: false, + PageRanges: "", } } @@ -142,23 +145,35 @@ func (p chromePrinter) Print(destination string) error { } else { p.logger.DebugOp(op, "no wait delay to apply, moving on...") } + printToPdfArgs := page.NewPrintToPDFArgs(). + SetPaperWidth(p.opts.PaperWidth). + SetPaperHeight(p.opts.PaperHeight). + SetMarginTop(p.opts.MarginTop). + SetMarginBottom(p.opts.MarginBottom). + SetMarginLeft(p.opts.MarginLeft). + SetMarginRight(p.opts.MarginRight). + SetLandscape(p.opts.Landscape). + SetDisplayHeaderFooter(true). + SetHeaderTemplate(p.opts.HeaderHTML). + SetFooterTemplate(p.opts.FooterHTML). + SetPrintBackground(true) + if p.opts.PageRanges != "" { + printToPdfArgs.SetPageRanges(p.opts.PageRanges) + } // print the page to PDF. + // TODO catch page range error? print, err := targetClient.Page.PrintToPDF( ctx, - page.NewPrintToPDFArgs(). - SetPaperWidth(p.opts.PaperWidth). - SetPaperHeight(p.opts.PaperHeight). - SetMarginTop(p.opts.MarginTop). - SetMarginBottom(p.opts.MarginBottom). - SetMarginLeft(p.opts.MarginLeft). - SetMarginRight(p.opts.MarginRight). - SetLandscape(p.opts.Landscape). - SetDisplayHeaderFooter(true). - SetHeaderTemplate(p.opts.HeaderHTML). - SetFooterTemplate(p.opts.FooterHTML). - SetPrintBackground(true), + printToPdfArgs, ) if err != nil { + if strings.Contains(err.Error(), "Page range syntax error") { + return xerror.Invalid( + "", + fmt.Sprintf("'%s' is not a valid Google Chrome page ranges", p.opts.PageRanges), + err, + ) + } return err } if err := ioutil.WriteFile(destination, print.Data, 0644); err != nil { diff --git a/internal/pkg/printer/office.go b/internal/pkg/printer/office.go index 8a21ff2e..7112acda 100644 --- a/internal/pkg/printer/office.go +++ b/internal/pkg/printer/office.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/phayes/freeport" "github.com/thecodingmachine/gotenberg/internal/pkg/conf" @@ -26,6 +27,7 @@ type officePrinter struct { type OfficePrinterOptions struct { WaitTimeout float64 Landscape bool + PageRanges string } // DefaultOfficePrinterOptions returns the default @@ -34,6 +36,7 @@ func DefaultOfficePrinterOptions(config conf.Config) OfficePrinterOptions { return OfficePrinterOptions{ WaitTimeout: config.DefaultWaitTimeout(), Landscape: false, + PageRanges: "", } } @@ -59,7 +62,7 @@ func (p officePrinter) Print(destination string) error { baseFilename := xrand.Get() tmpDest := fmt.Sprintf("%s/%d%s.pdf", dirPath, i, baseFilename) p.logger.DebugfOp(op, "converting '%s' to PDF...", fpath) - if err := unoconv(ctx, p.logger, fpath, tmpDest, p.opts); err != nil { + if err := p.unoconv(ctx, fpath, tmpDest); err != nil { return err } p.logger.DebugfOp(op, "'%s.pdf' created", baseFilename) @@ -85,9 +88,12 @@ func (p officePrinter) Print(destination string) error { return nil } -func unoconv(ctx context.Context, logger xlog.Logger, fpath, destination string, opts OfficePrinterOptions) error { +func (p officePrinter) unoconv(ctx context.Context, fpath, destination string) error { const op string = "printer.unoconv" resolver := func() error { + hasPageRanges := func() bool { + return p.opts.PageRanges != "" && len(p.fpaths) == 1 + } port, err := freeport.GetFreePort() if err != nil { return err @@ -100,11 +106,24 @@ func unoconv(ctx context.Context, logger xlog.Logger, fpath, destination string, "--format", "pdf", } - if opts.Landscape { + if p.opts.Landscape { args = append(args, "--printer", "PaperOrientation=landscape") } + if hasPageRanges() { + args = append(args, "--export", fmt.Sprintf("PageRange=%s", p.opts.PageRanges)) + } args = append(args, "--output", destination, fpath) - return xexec.Run(ctx, logger, "unoconv", args...) + if err := xexec.Run(ctx, p.logger, "unoconv", args...); err != nil { + if hasPageRanges() && strings.Contains(err.Error(), "exit status 5") { + return xerror.Invalid( + "", + fmt.Sprintf("'%s' is not a valid LibreOffice page ranges", p.opts.PageRanges), + err, + ) + } + return err + } + return nil } if err := resolver(); err != nil { return xerror.New(op, err) From 60c069cb1ff6c276452e0f77a286be1e06bb43e1 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 4 Oct 2019 18:19:13 +0200 Subject: [PATCH 2/6] updating documention with pageRanges --- build/docs/content/04-html.md | 48 ++++++++++++++ build/docs/content/07-office.md | 52 +++++++++++++++ docs/index.html | 112 ++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) diff --git a/build/docs/content/04-html.md b/build/docs/content/04-html.md index 4eae9357..e008cda7 100644 --- a/build/docs/content/04-html.md +++ b/build/docs/content/04-html.md @@ -347,3 +347,51 @@ $request->setWaitDelay(5.5); $dest = "result.pdf"; $client->store($request, $dest); ``` + +## Page ranges + +You may specify the page ranges to convert. + +The format is the same as the one from the print options +of Google Chrome, e.g. `1-5,8,11-13`. + +### cURL + +```bash +$ curl --request POST \ + --url http://localhost:3000/convert/html \ + --header 'Content-Type: multipart/form-data' \ + --form files=@index.html \ + --form pageRanges='1-3,5' \ + -o result.pdf +``` + +### Go + +```golang +import "github.com/thecodingmachine/gotenberg-go-client/v6" + +func main() { + c := &gotenberg.Client{Hostname: "http://localhost:3000"} + req, _ := gotenberg.NewHTMLRequest("index.html") + req.PageRanges("1-3,5") + dest := "result.pdf" + c.Store(req, dest) +} +``` + +### PHP + +```php +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', 'index.html'); +$request = new HTMLRequest($index); +$request->setPageRanges("1-3,5"); +$dest = "result.pdf"; +$client->store($request, $dest); +``` diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index 39e91e37..74745587 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -115,3 +115,55 @@ $request->setLandscape(true); $dest = "result.pdf"; $client->store($request, $dest); ``` + +## Page ranges + +You may specify the page ranges to convert. + +The format is the same as the one from the print options +of LibreOffice, e.g. `1-1` or `1-4`. + +> This feature does not work in there is more +> than one document to convert. + +### cURL + +```bash +$ curl --request POST \ + --url http://localhost:3000/convert/office \ + --header 'Content-Type: multipart/form-data' \ + --form files=@document.docx \ + --form pageRanges='1-3' \ + -o result.pdf +``` + +### Go + +```golang +import "github.com/thecodingmachine/gotenberg-go-client/v6" + +func main() { + c := &gotenberg.Client{Hostname: "http://localhost:3000"} + req, _ := gotenberg.NewOfficeRequest("document.docx") + req.PageRanges("1-3") + dest := "result.pdf" + c.Store(req, dest) +} +``` + +### PHP + +```php +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', 'document.docx'), +]; +$request = new OfficeRequest($files); +$request->setPageRanges("1-3"); +$dest = "result.pdf"; +$client->store($request, $dest); +``` diff --git a/docs/index.html b/docs/index.html index 9b004cb1..cbf92684 100755 --- a/docs/index.html +++ b/docs/index.html @@ -724,6 +724,59 @@ $request = new HTMLRequest($index); $request->setWaitDelay(5.5); $dest = "result.pdf"; $client->store($request, $dest); + + +

Page ranges

+ +

You may specify the page ranges to convert.

+ +

The format is the same as the one from the print options +of Google Chrome, e.g. 1-5,8,11-13.

+ +

cURL

+ +
$ curl --request POST \
+    --url http://localhost:3000/convert/html \
+    --header 'Content-Type: multipart/form-data' \
+    --form files=@index.html \
+    --form pageRanges='1-3,5' \
+    -o result.pdf
+
+ +

Go

+ +
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
+func main() {
+    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+    req, _ := gotenberg.NewHTMLRequest("index.html")
+    req.PageRanges("1-3,5")
+    dest := "result.pdf"
+    c.Store(req, dest)
+}
+
+ +

PHP

+ +
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', 'index.html');
+$request = new HTMLRequest($index);
+$request->setPageRanges("1-3,5");
+$dest = "result.pdf";
+$client->store($request, $dest);
 
@@ -1001,6 +1054,65 @@ $request = new OfficeRequest($files); $request->setLandscape(true); $dest = "result.pdf"; $client->store($request, $dest); + + +

Page ranges

+ +

You may specify the page ranges to convert.

+ +

The format is the same as the one from the print options +of LibreOffice, e.g. 1-1 or 1-4.

+ +
+

This feature does not work in there is more +than one document to convert.

+
+ +

cURL

+ +
$ curl --request POST \
+    --url http://localhost:3000/convert/office \
+    --header 'Content-Type: multipart/form-data' \
+    --form files=@document.docx \
+    --form pageRanges='1-3' \
+    -o result.pdf
+
+ +

Go

+ +
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
+func main() {
+    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+    req, _ := gotenberg.NewOfficeRequest("document.docx")
+    req.PageRanges("1-3")
+    dest := "result.pdf"
+    c.Store(req, dest)
+}
+
+ +

PHP

+ +
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', 'document.docx'),
+];
+$request = new OfficeRequest($files);
+$request->setPageRanges("1-3");
+$dest = "result.pdf";
+$client->store($request, $dest);
 
From 827060b6cec5c5a290b88222b71cf8f65ff477f6 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 4 Oct 2019 18:22:46 +0200 Subject: [PATCH 3/6] emphazing that pageRanges does not work if more than one office document --- build/docs/content/07-office.md | 2 +- docs/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index 74745587..5cded130 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -123,7 +123,7 @@ You may specify the page ranges to convert. The format is the same as the one from the print options of LibreOffice, e.g. `1-1` or `1-4`. -> This feature does not work in there is more +> **Attention:** this feature does not work in there is more > than one document to convert. ### cURL diff --git a/docs/index.html b/docs/index.html index cbf92684..fbc2a471 100755 --- a/docs/index.html +++ b/docs/index.html @@ -1066,7 +1066,7 @@ $client->store($request, $dest); of LibreOffice, e.g. 1-1 or 1-4.

-

This feature does not work in there is more +

Attention: this feature does not work in there is more than one document to convert.

From ca0784fa594f7883400a47edd5dc0ecef118a26f Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Sat, 5 Oct 2019 12:09:39 +0200 Subject: [PATCH 4/6] adding tests for page ranges --- internal/app/xhttp/pkg/resource/arg_test.go | 1 + internal/pkg/printer/chrome.go | 4 ++-- internal/pkg/printer/html_test.go | 20 +++++++++++++++++++ internal/pkg/printer/markdown_test.go | 22 +++++++++++++++++++++ internal/pkg/printer/office.go | 10 ++++------ internal/pkg/printer/office_test.go | 20 +++++++++++++++++++ internal/pkg/printer/url_test.go | 20 +++++++++++++++++++ 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/internal/app/xhttp/pkg/resource/arg_test.go b/internal/app/xhttp/pkg/resource/arg_test.go index 3c7f6b02..f42fd1d0 100644 --- a/internal/app/xhttp/pkg/resource/arg_test.go +++ b/internal/app/xhttp/pkg/resource/arg_test.go @@ -24,6 +24,7 @@ func TestArgKeys(t *testing.T) { MarginLeftArgKey, MarginRightArgKey, LandscapeArgKey, + PageRangesArgKey, } assert.Equal(t, expected, ArgKeys()) } diff --git a/internal/pkg/printer/chrome.go b/internal/pkg/printer/chrome.go index f7cca718..41b4c99d 100644 --- a/internal/pkg/printer/chrome.go +++ b/internal/pkg/printer/chrome.go @@ -161,15 +161,15 @@ func (p chromePrinter) Print(destination string) error { printToPdfArgs.SetPageRanges(p.opts.PageRanges) } // print the page to PDF. - // TODO catch page range error? print, err := targetClient.Page.PrintToPDF( ctx, printToPdfArgs, ) if err != nil { + // TODO: find a way to check it in the handlers. if strings.Contains(err.Error(), "Page range syntax error") { return xerror.Invalid( - "", + op, fmt.Sprintf("'%s' is not a valid Google Chrome page ranges", p.opts.PageRanges), err, ) diff --git a/internal/pkg/printer/html_test.go b/internal/pkg/printer/html_test.go index 4a233163..e69539fa 100644 --- a/internal/pkg/printer/html_test.go +++ b/internal/pkg/printer/html_test.go @@ -38,6 +38,26 @@ func TestHTMLPrinter(t *testing.T) { assert.Nil(t, err) err = os.RemoveAll(dest) assert.Nil(t, err) + // options with a page ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "1" + p = NewHTMLPrinter(logger, fpath, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + assert.Nil(t, err) + err = os.RemoveAll(dest) + assert.Nil(t, err) + // should not be OK as options have + // a wrong page ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "foo" + p = NewHTMLPrinter(logger, fpath, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + test.AssertError(t, err) + assert.Equal(t, xerror.InvalidCode, xerror.Code(err)) + err = os.RemoveAll(dest) + assert.Nil(t, err) // should not be OK as context.Context // should timeout. opts = DefaultChromePrinterOptions(config) diff --git a/internal/pkg/printer/markdown_test.go b/internal/pkg/printer/markdown_test.go index c5115a3a..9627cdea 100644 --- a/internal/pkg/printer/markdown_test.go +++ b/internal/pkg/printer/markdown_test.go @@ -40,6 +40,28 @@ func TestMarkdownPrinter(t *testing.T) { assert.Nil(t, err) err = os.RemoveAll(dest) assert.Nil(t, err) + // options with a page ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "1" + p, err = NewMarkdownPrinter(logger, fpath, opts) + assert.Nil(t, err) + dest = test.GenerateDestination() + err = p.Print(dest) + assert.Nil(t, err) + err = os.RemoveAll(dest) + assert.Nil(t, err) + // should not be OK as options have + // a wrong page ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "foo" + p, err = NewMarkdownPrinter(logger, fpath, opts) + assert.Nil(t, err) + dest = test.GenerateDestination() + err = p.Print(dest) + test.AssertError(t, err) + assert.Equal(t, xerror.InvalidCode, xerror.Code(err)) + err = os.RemoveAll(dest) + assert.Nil(t, err) // should not be OK as context.Context // should timeout. opts = DefaultChromePrinterOptions(config) diff --git a/internal/pkg/printer/office.go b/internal/pkg/printer/office.go index 7112acda..e0f4f20b 100644 --- a/internal/pkg/printer/office.go +++ b/internal/pkg/printer/office.go @@ -91,9 +91,6 @@ func (p officePrinter) Print(destination string) error { func (p officePrinter) unoconv(ctx context.Context, fpath, destination string) error { const op string = "printer.unoconv" resolver := func() error { - hasPageRanges := func() bool { - return p.opts.PageRanges != "" && len(p.fpaths) == 1 - } port, err := freeport.GetFreePort() if err != nil { return err @@ -109,14 +106,15 @@ func (p officePrinter) unoconv(ctx context.Context, fpath, destination string) e if p.opts.Landscape { args = append(args, "--printer", "PaperOrientation=landscape") } - if hasPageRanges() { + if p.opts.PageRanges != "" { args = append(args, "--export", fmt.Sprintf("PageRange=%s", p.opts.PageRanges)) } args = append(args, "--output", destination, fpath) if err := xexec.Run(ctx, p.logger, "unoconv", args...); err != nil { - if hasPageRanges() && strings.Contains(err.Error(), "exit status 5") { + // TODO: find a way to check it in the handlers. + if p.opts.PageRanges != "" && strings.Contains(err.Error(), "exit status 5") { return xerror.Invalid( - "", + op, fmt.Sprintf("'%s' is not a valid LibreOffice page ranges", p.opts.PageRanges), err, ) diff --git a/internal/pkg/printer/office_test.go b/internal/pkg/printer/office_test.go index b6a0235b..5eb8992e 100644 --- a/internal/pkg/printer/office_test.go +++ b/internal/pkg/printer/office_test.go @@ -46,6 +46,26 @@ func TestOfficePrinter(t *testing.T) { assert.Nil(t, err) err = os.RemoveAll(dest) assert.Nil(t, err) + // options with page ranges. + opts = DefaultOfficePrinterOptions(config) + opts.PageRanges = "1-1" + p = NewOfficePrinter(logger, []string{fpaths[0]}, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + assert.Nil(t, err) + err = os.RemoveAll(dest) + assert.Nil(t, err) + // should not be OK as options have + // a wrong page ranges. + opts = DefaultOfficePrinterOptions(config) + opts.PageRanges = "foo" + p = NewOfficePrinter(logger, []string{fpaths[0]}, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + test.AssertError(t, err) + assert.Equal(t, xerror.InvalidCode, xerror.Code(err)) + err = os.RemoveAll(dest) + assert.Nil(t, err) // should not be OK as context.Context // should timeout. opts = DefaultOfficePrinterOptions(config) diff --git a/internal/pkg/printer/url_test.go b/internal/pkg/printer/url_test.go index 2c0b99f7..ef477e75 100644 --- a/internal/pkg/printer/url_test.go +++ b/internal/pkg/printer/url_test.go @@ -38,6 +38,26 @@ func TestURLPrinter(t *testing.T) { assert.Nil(t, err) err = os.RemoveAll(dest) assert.Nil(t, err) + // options with a pages ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "1" + p = NewURLPrinter(logger, URL, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + assert.Nil(t, err) + err = os.RemoveAll(dest) + assert.Nil(t, err) + // should not be OK as options have + // a wrong page ranges. + opts = DefaultChromePrinterOptions(config) + opts.PageRanges = "foo" + p = NewURLPrinter(logger, URL, opts) + dest = test.GenerateDestination() + err = p.Print(dest) + test.AssertError(t, err) + assert.Equal(t, xerror.InvalidCode, xerror.Code(err)) + err = os.RemoveAll(dest) + assert.Nil(t, err) // should not be OK as context.Context // should timeout. opts = DefaultChromePrinterOptions(config) From 3255f8af0c1f0efe6da9e545233b044dac3d9580 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Sat, 5 Oct 2019 12:13:06 +0200 Subject: [PATCH 5/6] updating documentation: if office and more than one document, page ranges will be applied for each of them --- build/docs/content/07-office.md | 4 ++-- docs/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index 5cded130..546ee7de 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -123,8 +123,8 @@ You may specify the page ranges to convert. The format is the same as the one from the print options of LibreOffice, e.g. `1-1` or `1-4`. -> **Attention:** this feature does not work in there is more -> than one document to convert. +> **Attention:** if more than one document, the page ranges will be +> applied for each document. ### cURL diff --git a/docs/index.html b/docs/index.html index fbc2a471..b03e62e3 100755 --- a/docs/index.html +++ b/docs/index.html @@ -1066,8 +1066,8 @@ $client->store($request, $dest); of LibreOffice, e.g. 1-1 or 1-4.

-

Attention: this feature does not work in there is more -than one document to convert.

+

Attention: if more than one document, the page ranges will be +applied for each document.