Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
添加密码以保护文档c#_C#_Asp.net_Pdf_Passwords_Document - Fatal编程技术网

添加密码以保护文档c#

添加密码以保护文档c#,c#,asp.net,pdf,passwords,document,C#,Asp.net,Pdf,Passwords,Document,我已经创建了一个pdf文档,我需要使用密码保护该文档 Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10); string pdfFilename = "dbtopdf.pdf"; PdfWriter.GetInstance(document, new FileStream(pdfFilename, FileMode.Create)); PdfPTable

我已经创建了一个pdf文档,我需要使用密码保护该文档

  Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);
        string pdfFilename = "dbtopdf.pdf";
        PdfWriter.GetInstance(document, new FileStream(pdfFilename, FileMode.Create));
        PdfPTable table = new PdfPTable(13);
        foreach (abccreation obj in list)
        {
       "Adding cell here... Not related"
        }
        document.Open();
        document.Add(table);
        document.Close();
请问有没有办法在文档中添加密码。因此,当用户试图读取此信息时,它将提示用户输入密码。 我已尝试使用
pdf.SecuritySettings.UserPassword=“您的密码”


但不知何故,我创建的这个文档不是pdf文件,所以同样的技术无法应用

什么样的文件?任何或特定格式,如
docx
?可能的副本我不知道我创建的文档的格式是什么。或者有没有什么方法可以让我将文档转换成pdf格式?@TienNguyen不同的是,这些方法只能应用于pdf文件,我很难将密码应用于我的文档,我不知道它的格式,但它不是pdf。“我不知道我创建的文档的格式”-嗯,您可以使用iTextSharp,这是一个用于生成PDF的库。因此,我假设您创建了一个PDF。。。