使用iframe阻止从pdf文件下载选项 [英] Preventing download Option from pdf file using iframe

查看:4448
本文介绍了使用iframe阻止从pdf文件下载选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   asp:Panel     ID   =  pnlDisplay     runat   =  server   可见  =  true   宽度  =  100% > ;  
< iframe width = 70 0px runat = server height = 800px id = myPDF > ; < / iframe >
< / asp:Panel >



  protected   void  grdArticles_RowCommand( object  sender,GridViewCommandEventArgs e)
{
if (e.CommandName == View
{
DataSet ds = obj.getArticlebyId(Convert.ToInt32(e.CommandArgument));
if (ds.Tables [ 0 ]。Rows.Count > 0
{
lblTitle.Text = ds.Tables [ 0 ]。行[ 0 ] [ ArticleTitle]的ToString();
lblAritcalContent.Text = ds.Tables [ 0 ]。行[ 0 ] [ ArticleContent]。ToString();
string pdffile = ds.Tables [ 0 ]。行[ 0 ] [ PdfPath]。ToString();
// string pdf1 =PdfArtical /+Test.pdf+#toolbar = 0& navpanes = 0;
string pdf1 = pdffile;
myPDF.Attributes.Add( src,pdf1.ToString());
// myPDF.Style.Add(display,none);
}
其他
{
}
}
}



从这里我想限制下载和打印选项请帮助我..

解决方案

您无法在浏览器中控制此功能。

一种方法是从pdf文件生成图像并在浏览器中显示,但这与显示PDF相同,因为用户可以下载图像。即使您能够控制此用户也可以拍摄屏幕截图并保存在硬盘上。



您可以尝试此控件没有安装在客户端或服务器上的Acrobat Reader的ASP.NET PDF Viewer用户控件 [ ^ ]

<asp:Panel ID="pnlDisplay" runat="server" Visible="true" Width="100%">
   <iframe width="700px" runat="server" height="800px" id="myPDF"></iframe>
</asp:Panel>


protected void grdArticles_RowCommand(object sender, GridViewCommandEventArgs e)
{
   if (e.CommandName == "View")
   {
      DataSet ds = obj.getArticlebyId(Convert.ToInt32(e.CommandArgument));
      if (ds.Tables[0].Rows.Count > 0)
      {
         lblTitle.Text = ds.Tables[0].Rows[0]["ArticleTitle"].ToString();
         lblAritcalContent.Text = ds.Tables[0].Rows[0]["ArticleContent"].ToString();
         string pdffile = ds.Tables[0].Rows[0]["PdfPath"].ToString();
         //string pdf1 = "PdfArtical/" + "Test.pdf" + "#toolbar=0&navpanes=0";
         string pdf1 = pdffile;
         myPDF.Attributes.Add("src", pdf1.ToString());
         //myPDF.Style.Add("display", "none");
      }
      else
      {
      }
   }
}


From Here I want to restrict download and print Option Please help me..

解决方案

You cannot control this functionality in browser.
One way is to generate image from pdf file and display in browser but this is same as showing PDF because user can download images. Even if you able to control this user can take screen shots and save on harddisk.

You can try this control ASP.NET PDF Viewer User Control Without Acrobat Reader Installed on Client or Server[^].


这篇关于使用iframe阻止从pdf文件下载选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆