Skip to content

Commit

Permalink
feat(libreoffice): add singlePageSheets
Browse files Browse the repository at this point in the history
  • Loading branch information
gulien committed Apr 11, 2024
1 parent a8759e5 commit 9a103a7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,19 @@ $request = Gotenberg::libreOffice($apiUrl)
->convert(Stream::path('/path/to/my.docx'));
```

#### Single page sheets

You may set whether to render the entire spreadsheet as a single page:

```php
use Gotenberg\Gotenberg;
use Gotenberg\Stream;

$request = Gotenberg::libreOffice($apiUrl)
->singlePageSheets()
->convert(Stream::path('/path/to/my.xlsx'));
```

#### PDF/A & PDF/UA

See https://gotenberg.dev/docs/routes#pdfa-libreoffice.
Expand Down
10 changes: 10 additions & 0 deletions src/Modules/LibreOffice.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function exportFormFields(bool $export = true): self
return $this;
}

/**
* Set whether to render the entire spreadsheet as a single page.
*/
public function singlePageSheets(): self
{
$this->formValue('singlePageSheets', true);

return $this;
}

/**
* Sets the PDF/A format of the resulting PDF.
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/Modules/LibreOfficeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function (
bool $landscape = false,
string|null $nativePageRanges = null,
bool|null $exportFormFields = null,
bool $singlePageSheets = false,
string|null $pdfa = null,
bool $pdfua = false,
array $metadata = [],
Expand All @@ -37,6 +38,10 @@ function (
$libreOffice->exportFormFields($exportFormFields);
}

if ($singlePageSheets) {
$libreOffice->singlePageSheets();
}

if ($pdfa !== null) {
$libreOffice->pdfa($pdfa);
}
Expand All @@ -62,6 +67,7 @@ function (
expect($body)->unless($landscape === false, fn ($body) => $body->toContainFormValue('landscape', '1'));
expect($body)->unless($nativePageRanges === null, fn ($body) => $body->toContainFormValue('nativePageRanges', $nativePageRanges));
expect($body)->unless($exportFormFields === null, fn ($body) => $body->toContainFormValue('exportFormFields', $exportFormFields === true ? '1' : '0'));
expect($body)->unless($singlePageSheets === false, fn ($body) => $body->toContainFormValue('singlePageSheets', '1'));
expect($body)->unless($merge === false, fn ($body) => $body->toContainFormValue('merge', '1'));

if (count($metadata) > 0) {
Expand Down Expand Up @@ -94,6 +100,7 @@ function (
true,
'1-2',
false,
true,
'PDF/A-1a',
true,
[ 'Producer' => 'Gotenberg' ],
Expand Down

0 comments on commit 9a103a7

Please sign in to comment.