English 中文(简体)
查看 pdf 文件,防止 c# 中的保存和打印选项
原标题:view pdf files and prevent save and print options in c#

I want to load my pdf file in a web page. The user should not have the provison to save or print the file. the below code opens the pdf file as attachment, but i want to open it directly in the page.

另请提供可以禁用 pdf 菜单栏的任何 Javascript 。

  Response.ContentType = "Application/pdf";
  Response.AppendHeader("content-disposition", "attachment; filename=" + old_filename + ".pdf");
  Response.TransmitFile(Server.MapPath("~/pdf_files/" + old_filename));
  Response.End();
问题回答

我想在网页上加载我的 pdf 文件。 用户不应该有保存或打印文件的附带条件 。

所以,您希望用户能够将 PDF 本地化( 这意味着文件本身必须可传输到本地计算机), 但是您不想让用户能够保存到本地吗? 不, 您不能这样做 。 您要么阻止信息离开您的机器, 要么您不这样做 。

您可以在服务器上将 PDF 转换成图像( 当然他们可以下载)- 但如果您向客户端提供 PDF 本身, 保存它总是微不足道的 。

不可能。 您可以使用 java 脚本功能在您的网页上停止右键点击( 然后用户不会通过右键点击 pdf/ image 获得保存菜单), 但是他们仍然可以在键盘上键入 ctrl+s 来保存页面 。

如果您想要删除保存功能, 您可以使用 iframe 显示您的 pdf 文件 。

另外,在您 pdf 链接的末尾加上“#toolbar=0”,用于 src 参数。

Take a look: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

_____________________________________________________________________________________________________________________________________________________________________________________________

对于打印功能,您可以保存您的 pdf 文件 。

Take a look: http://help.adobe.com/en_US/Acrobat/8.0w/Professional/help.html?content=WS58a04a822e3e50102bd615109794195ff-7e04.html





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签