Skip to content

Commit

Permalink
[RELEASE_8.14.0] Add new field generateDocumentOutline (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenRenaux authored Nov 20, 2024
1 parent bbdfaeb commit 7d86472
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Builder/Pdf/AbstractChromiumPdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ public function preferCssPageSize(bool $bool = true): static
return $this;
}

/**
* Define whether the document outline should be embedded into the PDF. (Default false).
*
* @see https://gotenberg.dev/docs/routes#page-properties-chromium
*/
public function generateDocumentOutline(bool $bool = true): static
{
$this->formFields['generateDocumentOutline'] = $bool;

return $this;
}

/**
* Prints the background graphics. (Default false).
*
Expand Down Expand Up @@ -575,6 +587,7 @@ protected function addConfiguration(string $configurationName, mixed $value): vo
'margin_left' => $this->marginLeft(...Unit::parse($value)),
'margin_right' => $this->marginRight(...Unit::parse($value)),
'prefer_css_page_size' => $this->preferCssPageSize($value),
'generate_document_outline' => $this->generateDocumentOutline($value),
'print_background' => $this->printBackground($value),
'omit_background' => $this->omitBackground($value),
'landscape' => $this->landscape($value),
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ private function addChromiumPdfOptionsNode(ArrayNodeDefinition $parent): void
->info('Define whether to prefer page size as defined by CSS - default false. https://gotenberg.dev/docs/routes#page-properties-chromium')
->defaultNull()
->end()
->booleanNode('generate_document_outline')
->info('Define whether the document outline should be embedded into the PDF - default false. https://gotenberg.dev/docs/routes#page-properties-chromium')
->defaultNull()
->end()
->booleanNode('print_background')
->info('Print the background graphics - default false. https://gotenberg.dev/docs/routes#page-properties-chromium')
->defaultNull()
Expand Down
3 changes: 3 additions & 0 deletions tests/Builder/Pdf/AbstractChromiumPdfBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static function configurationIsCorrectlySetProvider(): \Generator
yield 'prefer_css_page_size' => ['prefer_css_page_size', false, [
['preferCssPageSize' => 'false'],
]];
yield 'generate_document_outline' => ['generate_document_outline', false, [
['generateDocumentOutline' => 'false'],
]];
yield 'print_background' => ['print_background', false, [
['printBackground' => 'false'],
]];
Expand Down
3 changes: 3 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ private static function getBundleDefaultConfig(): array
'margin_left' => null,
'margin_right' => null,
'prefer_css_page_size' => null,
'generate_document_outline' => null,
'print_background' => null,
'omit_background' => null,
'landscape' => null,
Expand Down Expand Up @@ -271,6 +272,7 @@ private static function getBundleDefaultConfig(): array
'margin_left' => null,
'margin_right' => null,
'prefer_css_page_size' => null,
'generate_document_outline' => null,
'print_background' => null,
'omit_background' => null,
'landscape' => null,
Expand Down Expand Up @@ -299,6 +301,7 @@ private static function getBundleDefaultConfig(): array
'margin_left' => null,
'margin_right' => null,
'prefer_css_page_size' => null,
'generate_document_outline' => null,
'print_background' => null,
'omit_background' => null,
'landscape' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testGotenbergConfiguredWithValidConfig(): void
'margin_left' => 1,
'margin_right' => 1,
'prefer_css_page_size' => true,
'generate_document_outline' => true,
'print_background' => true,
'omit_background' => true,
'landscape' => true,
Expand Down Expand Up @@ -74,6 +75,7 @@ public function testGotenbergConfiguredWithValidConfig(): void
'margin_left' => 0.5,
'margin_right' => 0.5,
'prefer_css_page_size' => false,
'generate_document_outline' => false,
'print_background' => false,
'omit_background' => false,
'landscape' => false,
Expand All @@ -99,6 +101,7 @@ public function testGotenbergConfiguredWithValidConfig(): void
'margin_left' => 1,
'margin_right' => 1,
'prefer_css_page_size' => true,
'generate_document_outline' => true,
'print_background' => false,
'omit_background' => false,
'landscape' => true,
Expand Down Expand Up @@ -565,6 +568,7 @@ private static function getValidConfig(): array
'margin_left' => 1,
'margin_right' => 1,
'prefer_css_page_size' => true,
'generate_document_outline' => true,
'print_background' => true,
'omit_background' => true,
'landscape' => true,
Expand Down Expand Up @@ -597,6 +601,7 @@ private static function getValidConfig(): array
'margin_left' => 0.5,
'margin_right' => 0.5,
'prefer_css_page_size' => false,
'generate_document_outline' => false,
'print_background' => false,
'omit_background' => false,
'landscape' => false,
Expand All @@ -621,6 +626,7 @@ private static function getValidConfig(): array
'margin_left' => 1,
'margin_right' => 1,
'prefer_css_page_size' => true,
'generate_document_outline' => true,
'print_background' => false,
'omit_background' => false,
'landscape' => true,
Expand Down

0 comments on commit 7d86472

Please sign in to comment.