Hi,

I have been having emails recently after form submission with attached blank PDFs.

I tracked this issue down to the themeing function on line 583

$attachment->filecontent = theme('webform2pdf_mail2pdf', $webform2pdf_send2pdf['nid'], $webform2pdf_send2pdf['sid']);

I replaced it with

$attachment->filecontent = theme('webform2pdf_mail2pdf', array('nid' => $nid, 'sid' => $sid);

I created variables $nid and $sid above because it was easier for me

$nid = $message['params']['submission']->nid;
$sid = $message['params']['submission']->sid;

I'm not sure if this is relevant to anyone else but this was causing errors on my site until I changed the themeing function to use an array.

CommentFileSizeAuthor
#8 webform2pdf-email_pdfs-2240967-8.patch1.03 KBlunazoid

Comments

smoysauce’s picture

I am having the same issue, but cannot get your fix to work. I get a parse error.

Scratch that...I got the errors to go away but still blank PDF's only when e-mailed after submission, but also just realized I'm on the 7.x-4.x-dev version as I am using Webforms 4...sorry about that

roragok’s picture

I don't know what your issue is exactly but the error I was getting was that the line

$attachment->filecontent = theme('webform2pdf_mail2pdf', $webform2pdf_send2pdf['nid'], $webform2pdf_send2pdf['sid']);

was not passing in proper values.

$webform2pdf_send2pdf['nid']
and
$webform2pdf_send2pdf['sid']

were always sending 1 and 1 respectively to the themeing function.

but the proper values were still in the

$message['params']['submission']

I don't know if that is helpful to you.

smoysauce’s picture

Thanks I appreciate that. I attempted to make the changes, but no luck. Where did you add your $nid and $sid lines? In the new version, the 583 line is at line 200 or so. I will just have to keep looking and trying things out. Thanks again!

roragok’s picture

Are you still in this function?
function webform2pdf_mail_alter(&$message)
Sorry I haven't looked at the dev version.

My code looks like this for the area where I was having issues

 if ( $attach_pdf ) {
        $node = node_load($webform2pdf_send2pdf['nid']);
        $filename = theme('webform2pdf_filename', array('node' => $node, 'submission' => $webform2pdf_send2pdf['sid']));
        unset($node);
        $nid = $message['params']['submission']->nid;
        $sid = $message['params']['submission']->sid;
        if (webform_email_html_capable()) {
          if (module_exists('mimemail')) {
            $attachment = new stdClass;
            $attachment->filecontent = theme('webform2pdf_mail2pdf', array('nid'=>$nid,'sid'=>$sid));
            $attachment->filename = $filename;
            $attachment->filemime = 'application/pdf';
            $message['params']['attachments'][] = $attachment;
          }
        }
smoysauce’s picture

You rock! That fixed my problem. Thank you very much!!!

ecvandenberg’s picture

#4 also works for me with Webform 7.x-4.0-rc4. Thanx!

akkovanettinger’s picture

#4 solution worked for me too. using version 7.x-3.x
Shouldnt this be patched?

lunazoid’s picture

StatusFileSize
new1.03 KB

Was having the same issue with version 7.x-3.2. Thanks to solution posted by @Roragok in #4, it works! I'm submitting a patch which should also work in the dev version (actually created using the dev version, but the code is the same.) According to #6, the same changes should work in the 4.x branch, but I imagine the patch won't apply directly.

mr.york’s picture

Status: Active » Fixed

Thank you! Commited.

  • mr.york committed 6664868 on 7.x-3.x
    Issue #2328441, #2240967 by combert, lunazoid: Undefined variable:...

Status: Fixed » Closed (fixed)

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