【问题标题】:C# - Read DocumentPrivilege properties from a PDF fileC# - 从 PDF 文件中读取 DocumentPrivilege 属性
【发布时间】:2018-03-22 13:24:47
【问题描述】:

我正在使用 Aspose 库来读取、打开和保存 pdf 文件。 我正在寻找从属性“AllowModifyContents”中获取 pdf 文件安全值的方法。

这是这样设置的:

            using (var documenttosecure = new Aspose.Pdf.Document(inputFilePath))
            {
                using (var pdfOutput = new PdfFileSecurity(documenttosecure))
                {
                    var docP = DocumentPrivilege.AllowAll;

                    docP.AllowPrint = true;
                    docP.AllowCopy = true;
                    docP.AllowModifyContents = false;

                    pdfOutput.SetPrivilege(docP);

                    documenttosecure.Save(outputFile);
                }
            }

现在我需要获取该 pdf 并从 pdf DocumentPrivilege 中找到属性 AllowModifyContents。

你知道如何读取那个属性值吗?

感谢您的帮助; 塞尔吉奥

【问题讨论】:

    标签: c# pdf aspose


    【解决方案1】:

    Aspose.Pdf.Facades.PdfFileInfo类的GetDocumentPrivilege()方法,返回一个DocumentPrivilege类型的对象,通过它可以确定AllowModifyContents属性的值。请检查以下代码 sn-p,以实现您的要求。

    // Instantiate PdfFileInfo Class object.
    Aspose.Pdf.Facades.PdfFileInfo info = new Aspose.Pdf.Facades.PdfFileInfo();
    // Load your encrypted PDF document.
    info.BindPdf(dataDir + "EncryptedDocument.pdf");
    // Get DocumentPrivilege
    Facades.DocumentPrivilege documentPrivilege = info.GetDocumentPrivilege();
    // Determine AllowModifyContents
    bool AllowModifyContents = documentPrivilege.AllowModifyContents;
    

    注意:我是 Asad Ali,在 Aspose 担任开发人员宣传员。

    【讨论】:

    • 是的。这就是我一直在寻找的,而且效果很好。非常感谢阿萨德·阿里
    猜你喜欢
    • 2019-06-04
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2015-05-11
    • 1970-01-01
    • 2021-03-11
    相关资源
    最近更新 更多