Skip to content

Commit

Permalink
Add missing methods (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenRenaux committed Jun 10, 2024
1 parent 7447f99 commit d0c7748
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Builder/Pdf/LibreOfficePdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ public function nativePageRanges(string $range): self
return $this;
}

/**
* Set whether to export the form fields or to use the inputted/selected content of the fields.
*/
public function exportFormFields(bool $bool = false): self
{
$this->formFields['exportFormFields'] = $bool;

return $this;
}

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

return $this;
}

/**
* Convert the resulting PDF into the given PDF/A format.
*/
Expand Down Expand Up @@ -156,6 +176,8 @@ private function addConfiguration(string $configurationName, mixed $value): void
'pdf_universal_access' => $this->pdfUniversalAccess($value),
'landscape' => $this->landscape($value),
'native_page_ranges' => $this->nativePageRanges($value),
'export_form_fields' => $this->exportFormFields($value),
'single_page_sheets' => $this->singlePageSheets($value),
'merge' => $this->merge($value),
'metadata' => $this->metadata($value),
default => throw new InvalidBuilderConfiguration(sprintf('Invalid option "%s": no method does not exist in class "%s" to configured it.', $configurationName, static::class)),
Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ private function addPdfOfficeNode(): NodeDefinition
->thenInvalid('Invalid range values, the range value format need to look like e.g 1-20.')
->end()
->end()
->booleanNode('export_form_fields')
->info('Set whether to export the form fields or to use the inputted/selected content of the fields. - default true. https://gotenberg.dev/docs/routes#page-properties-libreoffice')
->defaultNull()
->end()
->booleanNode('single_page_sheets')
->info('Set whether to render the entire spreadsheet as a single page. - default false. https://gotenberg.dev/docs/routes#page-properties-libreoffice')
->defaultNull()
->end()
->booleanNode('merge')
->info('Merge alphanumerically the resulting PDFs. - default false. https://gotenberg.dev/docs/routes#merge-libreoffice')
->defaultNull()
Expand Down
6 changes: 6 additions & 0 deletions tests/Builder/Pdf/LibreOfficePdfBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public static function configurationIsCorrectlySetProvider(): \Generator
yield 'native_page_ranges' => ['native_page_ranges', '1-10', [
'nativePageRanges' => '1-10',
]];
yield 'export_form_fields' => ['export_form_fields', true, [
'exportFormFields' => 'true',
]];
yield 'single_page_sheets' => ['single_page_sheets', false, [
'singlePageSheets' => 'false',
]];
yield 'merge' => ['merge', false, [
'merge' => 'false',
]];
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ private static function getBundleDefaultConfig(): array
'office' => [
'landscape' => null,
'native_page_ranges' => null,
'export_form_fields' => null,
'single_page_sheets' => null,
'merge' => null,
'pdf_format' => null,
'pdf_universal_access' => null,
Expand Down

0 comments on commit d0c7748

Please sign in to comment.