Problem/Motivation
The entity print PDF's body is pulled from the webform element's display settings
and templates, specially, when we add an element of type 'Attachment PDF',
it possible choose between HTML or Table view modes. So one way to customize a
pdf body to each submission can be achieved with following steps:
1. Add an element to form of type 'Advanced HTML/Text'
2. Mark it to display on: viewed submission only
3. In this element, to build your custom layout using fields provided by tokens
4. Hide all others elements in admin/structure/webform/manage/contact/settings/submissions keeping only the created above
5. Add a new element of type 'Attachment PDF'
Now, you have a customized pdf filled with submission data and, but in the same time
we changed too the View page that displays the submission data.
Like when we send an email (image bellow), normally is preferable to have an
option to customize the body without change the submission view page. And more,
we could create multiple PDFs to same submission data, like we can create multiples
emails.
Proposed resolution
- create a new option inside 'Attachment PDF', allowing customize the pdf body, not related to submission view page
Remaining tasks
- Update webform_entity_print_attachment element
- Add #view_mode = 'custom'
- Add #template property element
- Update UI
- Update \Drupal\webform\WebformSubmissionViewBuilder::view
Notes
- Unset custom view mode after PDF is created
- Create webform submission element to render submission.