I think you need to convert to Blob and then use the link to create the download
blobToSaveAs(fileName: string, blob: Blob) {
try {
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
if (link.download !== undefined) { // feature detection
link.setAttribute('href', url);
link.setAttribute('download', fileName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
} catch (e) {
console.error('BlobToSaveAs error', e);
}
}
When converting to Blob you can provide the mime type to PDF. I don’t know that one by heart
Example:
const blob = new Blob([exportText], { type: 'text/plain' });