如何禁用PDF文档的“另存为”选项 [英] How to disable Save As option for a PDF document

查看:624
本文介绍了如何禁用PDF文档的“另存为”选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用保存PDF文档

解决方案

为什么要禁用它?即使你这样做了,你仍然可以使用其他方法下载PDF。


你好 解决方案使用这些代码
使用(MemoryStream输入= MemoryStream(renderedBytes))
{
使用(MemoryStream输出= MemoryStream())
{
PdfReader reader = new PdfReader(输入);
reader.AddViewerPreference(PdfName.HIDEMENUBAR,PdfName.NONE);
// PdfEncryptor.Encrypt(reader,output,true,CertificatePassword,CertificatePassword,PdfWriter.ALLOW_SCREENREADERS);
PdfEncryptor.Encrypt(reader,output, true null null ,PdfWriter.ALLOW_PRINTING | PdfWriter.AllowPrinting | PdfWriter.ENCRYPTION_AES_128 | PdfWriter.CenterWindow);
renderedBytes = output.ToArray();
Response.ContentType = application / pdf;

}
} i


How to disable Save a PDF document

解决方案

Why would you want to disable it? Even if you did, you could still download the PDF using other methods.


Hi here is the solution use these code
using (MemoryStream input = new MemoryStream(renderedBytes))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        PdfReader reader = new PdfReader(input);
                        reader.AddViewerPreference(PdfName.HIDEMENUBAR, PdfName.NONE);
                        // PdfEncryptor.Encrypt(reader, output, true, CertificatePassword, CertificatePassword, PdfWriter.ALLOW_SCREENREADERS);
                        PdfEncryptor.Encrypt(reader, output, true, null, null, PdfWriter.ALLOW_PRINTING | PdfWriter.AllowPrinting | PdfWriter.ENCRYPTION_AES_128 | PdfWriter.CenterWindow);
                        renderedBytes = output.ToArray();
                        Response.ContentType = "application/pdf";
                      
}
}"i


这篇关于如何禁用PDF文档的“另存为”选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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