Well I am using the following code to render a PDF that is returned from a webservice as base64 string.
<html>
<object data="data:application/pdf;base64,{!pdfStampingResponse.pdfBase64}" type="application/pdf" width="100%" class="internal">
<param name="view" value="fitH" />
</object>
</html>
This works well but I want to set the download filename when user tries to save the file. Somehow I am unable to find a working solution. Any idea how to do this ?
please try this
const FILE_NAME = 'myfile.pdf';
const file_header = ';headers=filename';
fetch('https:your-url/myfile.pdf?dl=0').then(r => r.blob())
.then(blob=>{
const f = new FileReader();
f.onload = () => myPdfViewer.src = f.result.replace(';', file_header + encodeURIComponent(FILE_NAME) + ';');
f.readAsDataURL(blob);
});
Then insert id myPdfViewer to an iframe. I hope it can help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With