I would like to be able to print individual webform submissions to PDF.

I have attempted to do this by creating a View Page to show individual submissions. e.g. http://website.localhost/webform/submission/25 using the webform_views module and the "Webform submission: Rendered entity" field to the display results.

The page displays great but when using the entity_print module to add a "view pdf" link on the page, the pdf is generated but it is blank.

I have tested the entity_print module on other page views and the PDF's are generating with content and I am now struggling to find an answer to why the webform_views data wont print to PDF.

I have created an issue for this https://www.drupal.org/node/2883205 but I am wondering if there is a smarter way I can achieve the printing of an individual submission to PDF directly with the webform module and not requiring webform_views.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danjordan created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
FileSize
1.81 KB

The entityprint.module module is looking a 'full' view mode, which was not supported by webform submissions.

The attached patch defaults any missing view mode to 'html' and outputs the submissions data with the submission information.

I think you are going to have write some custom preprocessing logic, templates, and CSS to make the output look pretty.

jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

danjordan’s picture

Thanks. I can confirm patch worked for me.

I did have to install the patch manually. When I updated the module via composer it said it updated with latest dev version but the patch was not implemented as part of the update.

There was a permission issue with webform images when generating the PDF's. The message was

"Error generating document: Failed to generate PDF: Image type unknown http://website.localhost/system/files/webform/service_checklist/27/test_..."

I had to enable the permission "View any webform submission" for "Anonymous User" for the PDF's to be created and including the image. Not sure if that is an issue with WebForm or Entity Print. I will open a new issue for it.

Thanks again Jacob.

Cheers
Dan

jrockowitz’s picture

Permissions problem should be handled in a new ticket in the Entity Print module's issue queue. If this is a Webform related issue the Entity Print module's maintainer can reassign it to the Webform module.

danjordan’s picture

Thanks. I have created a ticket for the issue. https://www.drupal.org/node/2883614

  • jrockowitz committed 648ce57 on 8.x-5.x
    Issue #2883402 by jrockowitz: Print individual webform submissions to...
benjy’s picture

Status: Fixed » Needs review
+++ b/src/WebformSubmissionViewBuilder.php
@@ -109,15 +109,32 @@ class WebformSubmissionViewBuilder extends EntityViewBuilder implements WebformS
+    if (in_array($view_mode, ['html', 'table', 'text', 'yaml'])) {
...
+      $display_submission_information = FALSE;
...
+      $display_submission_information  = TRUE;

I don't fully understand the use cases but there is the chance you can have the HTML view mode with and without submission information, is that correct?

jrockowitz’s picture

The Submission information (and navigation) is automatically include via \Drupal\webform\Controller\WebformSubmissionController::index.

jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.