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

Commit

Permalink
Merge pull request #12 from mdjward/feature/chrome-scaling-support
Browse files Browse the repository at this point in the history
Added "scale" option.
  • Loading branch information
gulien authored Feb 10, 2020
2 parents ad6ea58 + a541a5e commit 120fc00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 12 additions & 0 deletions src/ChromeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,6 +56,9 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac
/** @var int|null */
private $googleChromeRpccBufferSize;

/** @var float|null */
private $scale;

/**
* @return array<string,mixed>
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -198,4 +205,9 @@ public function setGoogleChromeRpccBufferSize(?int $googleChromeRpccBufferSize):
{
$this->googleChromeRpccBufferSize = $googleChromeRpccBufferSize;
}

public function setScale(?float $scale): void
{
$this->scale = $scale;
}
}
1 change: 1 addition & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 120fc00

Please sign in to comment.