Create custom form button that does not submit webform
Something like this may work.

#name and #submit are required.

The name makes sure the button does not get confused with other submit buttons.

The #submit value calls a custom function you have to create.

#limit_validation_errors prevents form validation, which may or may not be useful.

  $form['generate_pdf'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; $this-&gt;t('Generate PDF'),
    '#name' =&gt; 'generatepdf',
    '#submit' =&gt; ['::generatepdf'],
    '#limit_validation_errors' =&gt; array(),
  ];