[英]How to encrypt the data and open PDF in new tab when user click on link
when i user this window.open("data:application/pdf;base64, " + (response.fileContent)); 当我使用此window.open(“ data:application / pdf; base64,” +(response.fileContent)))时;
the problem with this is its opening browser tab like in address bar data://encrypted data. 问题是它打开了浏览器选项卡,如地址栏data:// encrypteddata中的。 i want to display there file name instead of it. 我想显示那里的文件名而不是它。
Can you please help me with this. 你能帮我这个忙吗?
To set the document.title
where the document is actually a data URI
you can use an HTML document
and set an <iframe>
src
to the data URI
of the .pdf
要将document.title
设置为document.title
实际上是data URI
,可以使用HTML document
并将<iframe>
src
设置为.pdf
的data URI
。
var data = `data:application/pdf;base64,${response.fileContent}`;
var title = "abc.pdf";
var html = `data:text/html,
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
</head>
<body>
<iframe src=${data} width="100%" height="600px"></iframe>
</body>
</html>`;
var w = window.open(html);
plnkr http://plnkr.co/edit/8gS7gBOEMPLjzqByMe4Z?p=preview plnkr http://plnkr.co/edit/8gS7gBOEMPLjzqByMe4Z?p=预览
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.