Webform module now supports printing PDF documents
To be competitive with enterprise form builders, the Webform module for Drupal 8 needs to support the downloading and exporting of submissions as PDF documents, as well as sending PDF documents as email attachments.
The Entity Print module does a great job of generating PDF documents from entities and fields, but webform submissions don't use Field API. This limitation has required site builders and developers to create custom Entity Print integrations for the Webform module.
The Webform module now includes a Webform Entity Print integration module, which handles downloading, exporting, and attaching generated PDF documents. Additionally, the Webform module allows the generated PDF document's header, footer, and CSS to be customized.
When enabled, Webform Entity Print module automatically displays a "Download PDF" link below all submissions and adds a download "PDF documents" option to the available export formats. Attaching PDF documents to emails requires that you add an "Attachment PDF" element to a webform and then configure email handlers to "Include files as attachments."
The below screencast and presentation walks through customizing the PDF link and template, exporting PDF documents, and attaching PDFs to emails.
Scratching my own itch
Adding PDF support was not a sponsored feature. I wanted the Webform module to support this advanced feature; so I created it. I was scratching my own itch.
When contributing to Drupal, the goal is often to optimize the project for personal needs ("scratching our own itch"), but it has to be bigger than that. https://www.drupal.org/about/values-and-principles
The bigger itch/the challenge that I am always scratching at is:
The Webform module should provide all the features expected from an enterprise proprietary form builder combined with the flexibility and openness of Drupal.
Competing with other form builders
Competitive enterprise, and also Open Source form builders, tend to put this PDF functionality behind a paywall. For example, WordPress's Gravity Form (https://gravitypdf.com/) and Ninja Form (https://ninjaforms.com/extensions/pdf-form-submission/) charge for this type of functionality. This defeats some of the purpose behind Open Source, which is to foster collaboration. For example, both of these form builders then had to implement PDF generation using custom APIs.
Ben shared his code
In the Drupal community, we openly share our code and APIs. Ben Dougherty (benjy), the maintainer of the Entity Print module, shared his code with the Drupal community. The Entity Print module is one the most well thought out and cleanly executed Drupal 8 modules that I have seen. Ben’s hard work made it easy (and enjoyable) for me to add PDF support to the Webform module.
Everyone should thank Benjy for building and maintaining the Entity Print module.
If you want to thank and encourage me to continue scratching my own itch, please also consider backing the Webform module’s Open Collective and help make the Webform module that much more awesome and more sustainable.