Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing methods for LibreOfficePdfBuilder #62

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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