From 5547ad7958f1d4708bee6fc4af70703ebeedd884 Mon Sep 17 00:00:00 2001 From: Steven Renaux Date: Fri, 7 Jun 2024 23:33:25 +0200 Subject: [PATCH] Add missing methods --- src/Builder/Pdf/LibreOfficePdfBuilder.php | 22 +++++++++++++++++++ src/DependencyInjection/Configuration.php | 8 +++++++ .../Builder/Pdf/LibreOfficePdfBuilderTest.php | 6 +++++ .../DependencyInjection/ConfigurationTest.php | 2 ++ 4 files changed, 38 insertions(+) diff --git a/src/Builder/Pdf/LibreOfficePdfBuilder.php b/src/Builder/Pdf/LibreOfficePdfBuilder.php index 876c000..c158b95 100644 --- a/src/Builder/Pdf/LibreOfficePdfBuilder.php +++ b/src/Builder/Pdf/LibreOfficePdfBuilder.php @@ -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. */ @@ -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)), diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e6e24e9..fc9baa6 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -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() diff --git a/tests/Builder/Pdf/LibreOfficePdfBuilderTest.php b/tests/Builder/Pdf/LibreOfficePdfBuilderTest.php index 95909ad..765a80d 100644 --- a/tests/Builder/Pdf/LibreOfficePdfBuilderTest.php +++ b/tests/Builder/Pdf/LibreOfficePdfBuilderTest.php @@ -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', ]]; diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index abca850..55555d3 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -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,