Customize the pdf body

Created on 2 August 2019, over 5 years ago
Updated 18 December 2023, 11 months ago

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.
✨ Feature request
Status

Fixed

Version

5.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil thiagogomesverissimo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States emont88

    It's been almost a couple years since the last comment here, but it would be great to have a feature like what @stleroux described--a way to build out the PDF twig template in a file rather than just within the webform form builder UI. Or maybe I'm missing a way to do that already exists?

    Also, is there any way to debug these generated Attachment PDFs? When generating PDFs with Entity Print the default way (not as an Attachment PDF), it is possible to debug the PDF in order to help with styling, etc. but there doesn't appear to be a way to debug these.

Production build 0.71.5 2024