PdfEncryptionDetails

PdfEncryptionDetails(string, string)

初始化此类的实例。

public PdfEncryptionDetails(string userPassword, string ownerPassword)

也可以看看


PdfEncryptionDetails(string, string, PdfPermissions)

初始化此类的实例。

public PdfEncryptionDetails(string userPassword, string ownerPassword, PdfPermissions permissions)

例子

演示如何设置已保存 PDF 文档的权限。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Hello world!");

// 扩展权限以允许编辑注释。
PdfEncryptionDetails encryptionDetails =
    new PdfEncryptionDetails("password", string.Empty, PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly);

// 创建一个“PdfSaveOptions”对象,我们可以将其传递给文档的“Save”方法
// 修改该方法将文档转换为 .PDF 的方式。
PdfSaveOptions saveOptions = new PdfSaveOptions();
// 通过“EncryptionDetails”属性启用加密。
saveOptions.EncryptionDetails = encryptionDetails;

// 当我们打开此文档时,我们需要提供密码才能访问其内容。
doc.Save(ArtifactsDir + "PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);

也可以看看