Version 3.1 not rendering webform field value to PDF

Created on 8 February 2023, over 1 year ago
Updated 15 February 2023, over 1 year ago

Dear all,

Thank you for this fantastic module. I use it with the webform and rules modules so that users can get a meeting attendance certificate in a PDF file. The use case is simple: user inputs his/her name in a field, submits the webform, receives an email with a pdf attached.

All was working until your last update. Allow me to be more precise, the PDF still gets generated after the user submission (rules trigger the email/the view uses the template I've assigned) but without the field "name" value.

I reverted to the previous version of the module (performed a backup before updating the website) and everything works again as expected, the field "name" value is "printed" in the PDF, user gets the email with attachment.

I'm not sure if I'm missing something that came with the new update or a simple bug. Since this is such a simple use case scenario I'm even more baffled! Could someone help me? It's not imperative to update the module but I would make sense in the near future.

Regards,
Miguel

πŸ› Bug report
Status

Closed: works as designed

Version

3.0

Component

Code

Created by

πŸ‡΅πŸ‡ΉPortugal miguelbraga

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

Comments & Activities

  • Issue created by @miguelbraga
  • πŸ‡¬πŸ‡§United Kingdom RickJ

    Which version exactly were you using previously?

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    Dear RickJ,

    I was using version 7.x-1.7.

  • πŸ‡¬πŸ‡§United Kingdom RickJ

    OK, thanks. I don't use webform live, only experimented a bit with it. I'll see what I can do to work out what's changed to affect the behaviour. May take a little while ...

  • πŸ‡¬πŸ‡§United Kingdom RickJ

    I've done a very simple test and it works OK.

    I installed the latest webform (7.x-4.25), created a webform node, then created a form with a single text field, and created a submission.

    I then created a view of type "webform submission", added a webform data field, which offered me the one form field I'd created. This is all on the master tab. The preview showed the value I'd submitted.

    Finally I added a PDF Page tab, gave it a path (no other changes), invoked the path and got a PDF with the field data displayed. This worked with all three PDF formats.

    The only thing I can think of is if you're using the view that was created under views-PDF 7.x.1.x, and have not updated any settings, there may be rendering issues. I suggest first try changing something so you can re-save the view. This will update the internal settings which may fix the problem. If that doesn't work, please try re-creating the view from scratch.

    Let me know the results - thanks.

  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΈπŸ‡ͺSweden killua99

    @RickJ, thanks for the follow up, and keep the 7.x-3.x branch alive for so long, I used to build up the base for Drupal 9 and 10. If find some time to test that release I will appreciate it, especially Grid style

    @miguelbraga let RickJ know with his findings if that helps.

    I set the status as need more info and set the version to the dev branch.

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    @RickJ Just tried your method, fiddled with the existing view but the result is the same. Then I created a new view, same method as yours, but again nothing gets printed. Reverted back to 7.x.1.x and everything works, old and new view...

    While on 3.x this came up:

    Warning: chr() expects parameter 1 to be int, string given in TCPDF_FONTS::unichr() (line 1671 of /home/.../public_html/sites/all/libraries/tcpdf/include/tcpdf_fonts.php).

    Deprecated function: Array and string offset access syntax with curly braces is deprecated in require_once() (line 16 of /home/.../public_html/sites/all/modules/views_pdf/views_pdf_template.php).

  • πŸ‡¬πŸ‡§United Kingdom RickJ

    Strange!

    Do you get a value for the field on a preview of the master tab?

    What version of TCPDF are you using? I have 6.3.5, some earlier versions have issues with PDP 8. I've just checked github, and the latest is 6.6.2!

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    Yes a get the value! That's why it's really strange...
    My version of TCPDF is 6.2.22, could this be the culprit?
    I'm still on PHP 7.4 (due to hosting) but plan to upgrade ASAP.

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    It isn't, just updated TCPDF to 6.3.5 and still no luck...

  • πŸ‡¬πŸ‡§United Kingdom RickJ

    Hmm, I'm confused. We both seem to have created the equivalent view with the same versions of software, but with different results. I really don't know where to go next.

    Version of webform? I'm using 7.x-4.25, not sure that would make any difference though.

    I'll have to have a think as to how to solve this.

    Could you attach an export of your view?

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    I'm also using webform 7.x-4.25, I try to keep things updated. Haven't migrated to PHP 8.x due to some of the modules behave weirdly.
    Follows an export of my view:

    $view = new view();
    $view->name = 'certificates';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'webform_submissions';
    $view->human_name = 'Meeting Certificate';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view->new_display('default', 'Master', 'default');
    $handler->display->display_options['title'] = 'Certificates';
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'role';
    $handler->display->display_options['access']['role'] = array(
    3 => '3',
    2 => '2',
    );
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'none';
    $handler->display->display_options['pager']['options']['offset'] = '0';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';
    /* Field: Webform submissions: Serial number */
    $handler->display->display_options['fields']['serial']['id'] = 'serial';
    $handler->display->display_options['fields']['serial']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['serial']['field'] = 'serial';
    $handler->display->display_options['fields']['serial']['exclude'] = TRUE;
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value']['id'] = 'value';
    $handler->display->display_options['fields']['value']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value']['field'] = 'value';
    $handler->display->display_options['fields']['value']['label'] = '';
    $handler->display->display_options['fields']['value']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value']['webform_cid'] = '1';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_1']['id'] = 'value_1';
    $handler->display->display_options['fields']['value_1']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_1']['field'] = 'value';
    $handler->display->display_options['fields']['value_1']['label'] = '';
    $handler->display->display_options['fields']['value_1']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_1']['webform_cid'] = '2';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_2']['id'] = 'value_2';
    $handler->display->display_options['fields']['value_2']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_2']['field'] = 'value';
    $handler->display->display_options['fields']['value_2']['label'] = 'E-mail Address';
    $handler->display->display_options['fields']['value_2']['exclude'] = TRUE;
    $handler->display->display_options['fields']['value_2']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_2']['webform_cid'] = '3';
    /* Contextual filter: Webform submissions: Sid */
    $handler->display->display_options['arguments']['sid']['id'] = 'sid';
    $handler->display->display_options['arguments']['sid']['table'] = 'webform_submissions';
    $handler->display->display_options['arguments']['sid']['field'] = 'sid';
    $handler->display->display_options['arguments']['sid']['default_action'] = 'empty';
    $handler->display->display_options['arguments']['sid']['default_argument_type'] = 'fixed';
    $handler->display->display_options['arguments']['sid']['summary']['number_of_records'] = '0';
    $handler->display->display_options['arguments']['sid']['summary']['format'] = 'default_summary';
    $handler->display->display_options['arguments']['sid']['summary_options']['items_per_page'] = '25';

    /* Display: Block */
    $handler = $view->new_display('block', 'Block', 'block');
    $handler->display->display_options['enabled'] = FALSE;

    /* Display: PDF Page */
    $handler = $view->new_display('pdf', 'PDF Page', 'pdf_1');
    $handler->display->display_options['style_plugin'] = 'pdf_unformatted';
    $handler->display->display_options['row_plugin'] = 'pdf_fields';
    $handler->display->display_options['row_options']['formats'] = array(
    'value_2' => array(
    'position' => array(
    'object' => 'page',
    'corner' => 'top_left',
    'x' => '19',
    'y' => '62',
    'width' => '',
    'height' => '',
    ),
    'text' => array(
    'font_size' => '',
    'font_family' => 'default',
    'font_style' => NULL,
    'align' => NULL,
    'hyphenate' => NULL,
    'color' => '',
    ),
    'render' => array(
    'is_html' => 0,
    'custom_layout' => 0,
    'minimal_space' => '1',
    ),
    ),
    );
    $handler->display->display_options['row_options']['leading_template'] = '0';
    $handler->display->display_options['row_options']['template'] = '0';
    $handler->display->display_options['row_options']['succeed_template'] = '0';
    $handler->display->display_options['defaults']['fields'] = FALSE;
    /* Field: Webform submissions: Serial number */
    $handler->display->display_options['fields']['serial']['id'] = 'serial';
    $handler->display->display_options['fields']['serial']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['serial']['field'] = 'serial';
    $handler->display->display_options['fields']['serial']['exclude'] = TRUE;
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value']['id'] = 'value';
    $handler->display->display_options['fields']['value']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value']['field'] = 'value';
    $handler->display->display_options['fields']['value']['label'] = '';
    $handler->display->display_options['fields']['value']['exclude'] = TRUE;
    $handler->display->display_options['fields']['value']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value']['webform_cid'] = '1';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_1']['id'] = 'value_1';
    $handler->display->display_options['fields']['value_1']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_1']['field'] = 'value';
    $handler->display->display_options['fields']['value_1']['label'] = '';
    $handler->display->display_options['fields']['value_1']['exclude'] = TRUE;
    $handler->display->display_options['fields']['value_1']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value_1']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_1']['webform_cid'] = '2';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_2']['id'] = 'value_2';
    $handler->display->display_options['fields']['value_2']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_2']['field'] = 'value';
    $handler->display->display_options['fields']['value_2']['label'] = '';
    $handler->display->display_options['fields']['value_2']['alter']['alter_text'] = TRUE;
    $handler->display->display_options['fields']['value_2']['alter']['text'] = '[value] [value_1]';
    $handler->display->display_options['fields']['value_2']['format'] = 'text';
    $handler->display->display_options['fields']['value_2']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value_2']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_2']['webform_cid'] = '3';
    $handler->display->display_options['path'] = 'viewspdf/%/webform.pdf';
    $handler->display->display_options['displays'] = array(
    'default' => 'default',
    'page_1' => 'page_1',
    'block' => 0,
    );
    $handler->display->display_options['default_page_orientation'] = 'L';
    $handler->display->display_options['leading_template'] = '0';
    $handler->display->display_options['template'] = 'palma-attendance-template.pdf';
    $handler->display->display_options['succeed_template'] = '0';
    $handler->display->display_options['default_font_family'] = 'latobi';
    $handler->display->display_options['default_font_style'] = array(
    'b' => 'b',
    'i' => 0,
    'u' => 0,
    'd' => 0,
    'o' => 0,
    );
    $handler->display->display_options['default_font_size'] = '28';

    /* Display: Page */
    $handler = $view->new_display('page', 'Page', 'page_1');
    $handler->display->display_options['defaults']['fields'] = FALSE;
    /* Field: Webform submissions: Serial number */
    $handler->display->display_options['fields']['serial']['id'] = 'serial';
    $handler->display->display_options['fields']['serial']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['serial']['field'] = 'serial';
    $handler->display->display_options['fields']['serial']['exclude'] = TRUE;
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value']['id'] = 'value';
    $handler->display->display_options['fields']['value']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value']['field'] = 'value';
    $handler->display->display_options['fields']['value']['label'] = '';
    $handler->display->display_options['fields']['value']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value']['webform_cid'] = '1';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_1']['id'] = 'value_1';
    $handler->display->display_options['fields']['value_1']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_1']['field'] = 'value';
    $handler->display->display_options['fields']['value_1']['label'] = '';
    $handler->display->display_options['fields']['value_1']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value_1']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_1']['webform_cid'] = '2';
    /* Field: Webform submission data: Value */
    $handler->display->display_options['fields']['value_2']['id'] = 'value_2';
    $handler->display->display_options['fields']['value_2']['table'] = 'webform_submissions';
    $handler->display->display_options['fields']['value_2']['field'] = 'value';
    $handler->display->display_options['fields']['value_2']['label'] = '';
    $handler->display->display_options['fields']['value_2']['alter']['alter_text'] = TRUE;
    $handler->display->display_options['fields']['value_2']['alter']['text'] = '[value] [value_1] [value_2]';
    $handler->display->display_options['fields']['value_2']['format'] = 'text';
    $handler->display->display_options['fields']['value_2']['custom_label'] = 'none';
    $handler->display->display_options['fields']['value_2']['webform_nid'] = '542';
    $handler->display->display_options['fields']['value_2']['webform_cid'] = '3';
    $handler->display->display_options['path'] = 'viewspdf/%/webform.pdf';

  • πŸ‡¬πŸ‡§United Kingdom RickJ

    It's just occurred to me this could be a manifestation of issue πŸ› Pdf content until "pdf unformatted" format is set for secont time Fixed .

    If so, then simply switching the display format to table or grid, and switching it back again, will fix it. The patch in that issue fixes the problem for newly created PDF views, but won't fix an existing one. Switching the format sorts it out.

    Please give it a try and let me know.

  • πŸ‡΅πŸ‡ΉPortugal miguelbraga

    @RickJ Yes the method of switching the display format to table or grid, and switching it back again seems to be working. I was able to render the values in the PDF. Do you think I should apply the views_pdf-initial_style-3201952-4.patch patch?
    Thank you for being considerate and for maintaining this fantastic module.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom RickJ

    Hi Miguel

    That's great to hear, I'd almost forgotten about that bug! Good to know it's sorted the problem.

    I'd recommend installing the patch, it simply changes the default format for a new PDF view to Table, so that you have to switch to use Unformatted, and that fixes the initialisation issue. Helps avoid the frustration you've just experienced!

    I will commit the patch to dev shortly, I think it's worth RTBC.

    I will close this issue now.

Production build 0.69.0 2024