简体   繁体   English

用户单击链接时如何加密数据并在新选项卡中打开PDF

[英]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设置为.pdfdata 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.

相关问题 如何在用户单击时在新选项卡中打开链接 - How can I open a link in a new tab when the user clicks it 用户单击时在新选项卡中打开链接 - Open link in new tab when user clicks 用户单击关闭选项卡时如何打开新窗口浏览器? - How to open new window browser when user click close tab? 当用户尝试在新标签页中打开链接时,如何在iframe中打开链接? - How to open a link inside of iframe when a user trys to open link in a new tab? 如何创建onPageLoad框,以便用户可以单击图像以在新选项卡中打开链接? - How to create onPageLoad box so that a user can click an image which open a link in new tab? 用户单击“在新选项卡中打开链接”时的通话功能 - call function when users click on “open link in new tab” 当 ctrl + 在 ReactJS 中单击它时,在新选项卡中打开链接? - Open link in new tab when ctrl + click it in ReactJS? 在新选项卡中单击弹出打开链接中的名称时? - When click name in popup open link in new tab? 如何在新选项卡中打开在 iframe 中的 PDF 文档中单击的链接? - How to open in a new tab a link clicked in a PDF document that is in an iframe? 即使用户单击“中间按钮”或右键单击-&gt;在新选项卡中打开,如何触发jquery“单击”事件 - How to trigger jquery “click” event even when the user clicked “middle button” or right click -> open in a new tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM