From a541a5e6cca9dbee7df59f25ca41df1a6737a234 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 1 Feb 2020 18:56:30 +0000 Subject: [PATCH] Added "scale" option. --- README.md | 1 + src/ChromeRequest.php | 12 ++++++++++++ tests/ClientTest.php | 1 + 3 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 1998be5..9efed62 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ try { $request->setAssets($assets); $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); + $request->setScale(0.75); # store method allows you to... store the resulting PDF in a particular destination. $client->store($request, 'path/you/want/the/pdf/to/be/stored.pdf'); diff --git a/src/ChromeRequest.php b/src/ChromeRequest.php index 3aec174..89b6dde 100644 --- a/src/ChromeRequest.php +++ b/src/ChromeRequest.php @@ -18,6 +18,7 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac private const LANDSCAPE = 'landscape'; private const PAGE_RANGES = 'pageRanges'; private const GOOGLE_CHROME_RPCC_BUFFER_SIZE = 'googleChromeRpccBufferSize'; + private const SCALE = 'scale'; /** @var float|null */ private $waitDelay; @@ -55,6 +56,9 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac /** @var int|null */ private $googleChromeRpccBufferSize; + /** @var float|null */ + private $scale; + /** * @return array */ @@ -88,6 +92,9 @@ public function getFormValues(): array if ($this->googleChromeRpccBufferSize !== null) { $values[self::GOOGLE_CHROME_RPCC_BUFFER_SIZE] = $this->googleChromeRpccBufferSize; } + if ($this->scale !== null) { + $values[self::SCALE] = $this->scale; + } $values[self::LANDSCAPE] = $this->landscape; return $values; @@ -198,4 +205,9 @@ public function setGoogleChromeRpccBufferSize(?int $googleChromeRpccBufferSize): { $this->googleChromeRpccBufferSize = $googleChromeRpccBufferSize; } + + public function setScale(?float $scale): void + { + $this->scale = $scale; + } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e295c22..380bb06 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -62,6 +62,7 @@ private function createHTMLRequest(): HTMLRequest $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); $request->setGoogleChromeRpccBufferSize(1048576); + $request->setScale(0.9); return $request; }