DocumentSecurity

DocumentSecurity enumeration

يتم استخدامه كقيمة لـSecurity property. يحدد مستوى أمان المستند كقيمة رقمية.

[Flags]
public enum DocumentSecurity

قيم

اسمقيمةوصف
None0لا توجد حالات أمان محددة بواسطة الخاصية.
PasswordProtected1المستند محمي بكلمة مرور. (ملاحظة: لم يتم رؤية أي مستند حتى الآن).
ReadOnlyRecommended2يجب فتح المستند للقراءة فقط إذا كان ذلك ممكنًا، ولكن يمكن تجاوز الإعداد.
ReadOnlyEnforced4المستند الذي سيتم فتحه دائمًا للقراءة فقط.
ReadOnlyExceptAnnotations8المستند الذي سيتم فتحه دائمًا للقراءة فقط باستثناء التعليقات التوضيحية.

أمثلة

يوضح كيفية استخدام خصائص المستند لعرض مستوى أمان المستند.

Document doc = new Document();

Assert.AreEqual(DocumentSecurity.None, doc.BuiltInDocumentProperties.Security);

// إذا قمنا بتكوين مستند ليكون للقراءة فقط، فسوف يعرض هذه الحالة باستخدام الخاصية المضمنة "الأمان".
doc.WriteProtection.ReadOnlyRecommended = true;
doc.Save(ArtifactsDir + "DocumentProperties.Security.ReadOnlyRecommended.docx");

Assert.AreEqual(DocumentSecurity.ReadOnlyRecommended, 
    new Document(ArtifactsDir + "DocumentProperties.Security.ReadOnlyRecommended.docx").BuiltInDocumentProperties.Security);

// قم بحماية المستند ضد الكتابة، ثم تحقق من مستوى الأمان الخاص به.
doc = new Document();

Assert.False(doc.WriteProtection.IsWriteProtected);

doc.WriteProtection.SetPassword("MyPassword");

Assert.True(doc.WriteProtection.ValidatePassword("MyPassword"));
Assert.True(doc.WriteProtection.IsWriteProtected);

doc.Save(ArtifactsDir + "DocumentProperties.Security.ReadOnlyEnforced.docx");

Assert.AreEqual(DocumentSecurity.ReadOnlyEnforced,
    new Document(ArtifactsDir + "DocumentProperties.Security.ReadOnlyEnforced.docx").BuiltInDocumentProperties.Security);

// "الأمان" خاصية وصفية. يُمكننا تعديل قيمتها يدويًا.
doc = new Document();

doc.Protect(ProtectionType.AllowOnlyComments, "MyPassword");
doc.BuiltInDocumentProperties.Security = DocumentSecurity.ReadOnlyExceptAnnotations;
doc.Save(ArtifactsDir + "DocumentProperties.Security.ReadOnlyExceptAnnotations.docx");

Assert.AreEqual(DocumentSecurity.ReadOnlyExceptAnnotations,
    new Document(ArtifactsDir + "DocumentProperties.Security.ReadOnlyExceptAnnotations.docx").BuiltInDocumentProperties.Security);

أنظر أيضا