I figured it out.
var file = res.toDataURI();
That gives me the base64 encoded pdf in a string. So, once I put that in the variable I just did an ajax call in javascript where I then handle the rest in .php.
$f = str_replace('data:application/pdf;base64,', '', $f);
file_put_contents( EMAIL_ATTACHMENTS .$file, $f);
$fp = fopen(EMAIL_ATTACHMENTS . $file, 'wb');
fwrite($fp, base64_decode($f));
fclose($fp);
That saves the pdf to the attachments file where I temporarily store the file to attach to emails using sendgrid.