Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit 120fc00

Browse files
author
Julien Neuhart
authoredFeb 10, 2020
Merge pull request #12 from mdjward/feature/chrome-scaling-support
Added "scale" option.
2 parents ad6ea58 + a541a5e commit 120fc00

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ try {
5656
$request->setAssets($assets);
5757
$request->setPaperSize(Request::A4);
5858
$request->setMargins(Request::NO_MARGINS);
59+
$request->setScale(0.75);
5960

6061
# store method allows you to... store the resulting PDF in a particular destination.
6162
$client->store($request, 'path/you/want/the/pdf/to/be/stored.pdf');

‎src/ChromeRequest.php

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac
1818
private const LANDSCAPE = 'landscape';
1919
private const PAGE_RANGES = 'pageRanges';
2020
private const GOOGLE_CHROME_RPCC_BUFFER_SIZE = 'googleChromeRpccBufferSize';
21+
private const SCALE = 'scale';
2122

2223
/** @var float|null */
2324
private $waitDelay;
@@ -55,6 +56,9 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac
5556
/** @var int|null */
5657
private $googleChromeRpccBufferSize;
5758

59+
/** @var float|null */
60+
private $scale;
61+
5862
/**
5963
* @return array<string,mixed>
6064
*/
@@ -88,6 +92,9 @@ public function getFormValues(): array
8892
if ($this->googleChromeRpccBufferSize !== null) {
8993
$values[self::GOOGLE_CHROME_RPCC_BUFFER_SIZE] = $this->googleChromeRpccBufferSize;
9094
}
95+
if ($this->scale !== null) {
96+
$values[self::SCALE] = $this->scale;
97+
}
9198
$values[self::LANDSCAPE] = $this->landscape;
9299

93100
return $values;
@@ -198,4 +205,9 @@ public function setGoogleChromeRpccBufferSize(?int $googleChromeRpccBufferSize):
198205
{
199206
$this->googleChromeRpccBufferSize = $googleChromeRpccBufferSize;
200207
}
208+
209+
public function setScale(?float $scale): void
210+
{
211+
$this->scale = $scale;
212+
}
201213
}

‎tests/ClientTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private function createHTMLRequest(): HTMLRequest
6262
$request->setPaperSize(Request::A4);
6363
$request->setMargins(Request::NO_MARGINS);
6464
$request->setGoogleChromeRpccBufferSize(1048576);
65+
$request->setScale(0.9);
6566

6667
return $request;
6768
}

0 commit comments

Comments
 (0)
This repository has been archived.