【问题标题】:iTextSharp - Password Protect PDF's [duplicate]iTextSharp - 密码保护 PDF 的 [重复]
【发布时间】:2015-04-25 20:12:57
【问题描述】:

我正在使用以下代码生成PDF's。我想password protect PDF。

如何使用密码保护iTextSharp 中的 PDF?

document = new Document(PageSize.A4, 10, 10, 25, 25);
output = new MemoryStream();
writer = PdfWriter.GetInstance(document, output);

document.Open();    
document.Add(OuterTable);    
document.Close();    

System.IO.File.WriteAllBytes(Server.MapPath("~/PDFs/" + name.ToString() + ".pdf"), output.ToArray());

【问题讨论】:

    标签: c# asp.net-mvc pdf itextsharp


    【解决方案1】:

    您可以使用 PdfEncryptor。 userPassword arg 将在其上设置密码。 http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfEncryptor.html

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 2013-07-14
    • 2012-09-09
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多