How to get Q & A of a webform submission? Main goal is to get user filled in form into a pdf. Got my pdf &amp; sending it with email. But I cant figure out how to get Q &amp; A from a submission. I have sid of submission. I tried

      $storage = \Drupal::entityTypeManager()-&gt;getStorage('webform_submission');
  $webform_submission = $storage-&gt;loadByProperties([
    'entity_type' =&gt; 'webform',
    'entity_id' =&gt; 'questionnaire',
  ]);
  $submission_data = array();
  foreach ($webform_submission as $submission) {
    $submission_data[] = $submission-&gt;getData();
  }


Webform is not attached to node. 

Thanks
Try below code:

module_load_include('inc','webform','includes/webform.submissions');
$sid = 10; //Replace this value with your dynamic sid value
$submission = webform_get_submissions(array('sid' =&gt; $sid));
$nid = $submission[$sid]-&gt;nid;

$web_submission = webform_get_submission($nid, $sid);
$node = node_load($nid);
$output = webform_submission_render($node, $web_submission, NULL, 'html');

print $output;