I have a PDF report in base64, I want to show a file embedded in an HTML page. For this, I use iFrame and it works, but the problem is that I can not set the PDF name so that when it is loaded it will be saved with the assigned name.
Can I set the file name ?, if so, how can I do this?
this is my code:
var iFrameBlock = $("<iframe>").attr({ "src": base64file_encode, "width": "100%", "height": "100%", "frameborder": "0" }); $("#previewPDF").html(iFrameBlock);
Result:
PDF previewAnd when I try to download the file, the name that needs to be saved is "download.pdf" Save the dialog
I tried different ways, but not working:
Adding download attribute = "filename.pdf"
var iFrameBlock = $("<iframe>").attr({ "src": base64file_encode, "width": "100%", "height": "100%", "frameborder": "0", "download": "filename.pdf" });
I tried to change the value inside the iframe, but I was able to find the correct attribute, and Chrome rejected the action.
var iframe = $("iframe")[0]; var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
However, I want to prevent the use of any other library.
thank you for your time
source share