Skip to content

Commit

Permalink
Fix header and Footer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenRenaux committed Dec 19, 2024
1 parent ee33766 commit 127364e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
24 changes: 24 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,30 @@ sensiolabs_gotenberg:
> For more information about the [PDF properties](https://gotenberg.dev/docs/routes#page-properties-chromium)
> or [screenshot properties](https://gotenberg.dev/docs/routes#screenshots-route).
## Header and footer defaults templates
You have the option to add a default header and/or footer template to your PDF.
If your template contains variables, simply enter its name and value under `context`
as shown below.

```yaml
sensiolabs_gotenberg:
http_client: 'gotenberg.client'
assets_directory: 'assets'
default_options:
pdf:
html:
header:
template: 'header.html.twig'
context:
- { name: 'title', value: 'Hello' }
- { name: 'first_name', value: 'Jean Michel' }
footer:
template: 'footer.html.twig'
context:
- { name: 'foo', value: 'bar' }
```

## Extra HTTP headers

HTTP headers to send by Chromium while loading the HTML document.
Expand Down
12 changes: 10 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,14 @@ private function addChromiumPdfOptionsNode(ArrayNodeDefinition $parent): void
->scalarNode('template')
->info('Default header twig template to apply.')
->defaultNull()
->isRequired()
->end()
->scalarNode('context')
->arrayNode('context')
->info('Default context for header twig template.')
->useAttributeAsKey('name')
->defaultValue([])
->variablePrototype()
->end()
->end()
->end()
->end()
Expand All @@ -185,10 +189,14 @@ private function addChromiumPdfOptionsNode(ArrayNodeDefinition $parent): void
->scalarNode('template')
->info('Default footer twig template to apply.')
->defaultNull()
->isRequired()
->end()
->scalarNode('context')
->arrayNode('context')
->info('Default context for footer twig template.')
->useAttributeAsKey('name')
->defaultValue([])
->variablePrototype()
->end()
->end()
->end()
->end()
Expand Down

0 comments on commit 127364e

Please sign in to comment.