Dompdf returns PDF on Controller function but not on Submit Form function
By default after form submit drupal makes a redirect, if there is no redirect defined intentionally allways will go to current url. To prevent this, you need call to disableRedirect() method from FormState at the final of submitForm().

Example:

public function submitForm(array &amp;$form, FormStateInterface $form_state)
{
    $dompdf = new Dompdf();
    $dompdf-&gt;loadHtml('&lt;h1&gt;hello world&lt;/h1&gt;');
    $dompdf-&gt;setPaper('A4');
    $dompdf-&gt;render();
    $dompdf-&gt;stream("example.pdf", array("Attachment"=&gt;0));
    if ($dompdf){
        drupal_set_message("DOMPDF");
    }
    foreach($form_state-&gt;getValues() as $key =&gt; $value){
        drupal_set_message($key . ': ' . $value);
    }
    // Prevent form redirection to print PDF.
    $form_state-&gt;disableRedirect();
}


Source: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormState.php/function/FormState%3A%3AdisableRedirect/8.2.x

Other option, more dirty, is call to exit() method from PHP (http://php.net/manual/es/function.exit.php) also at the final of the function.