private void UpdateProtectDocumentRestrictionProperties(PdfOperationsDesigner designer, IFunctionData data, AuthenticationType protection) { bool addDocumentRestrictions = data.Properties["Allow user access"].GetValue <bool>(); designer.Properties[PropertyNames.ProtectAddDocumentRestrictions].Value = addDocumentRestrictions; if (!addDocumentRestrictions) { return; } #pragma warning disable 618 Obsolete.Permissions oldPermissions = data.Properties["User permissions"].GetValue <Obsolete.Permissions>(); UpdateProtectAllowPrintingProperties(designer, oldPermissions); UpdateProtectAllowChangesProperties(designer, oldPermissions); designer.Properties[PropertyNames.ProtectAllowCopying].Value = oldPermissions.HasFlag(Obsolete.Permissions.AllowCopy); designer.Properties[PropertyNames.ProtectAllowScreenReaders].Value = oldPermissions.HasFlag(Obsolete.Permissions.AllowScreenreaders); #pragma warning restore 618 if (protection == AuthenticationType.Password) { designer.Properties[PropertyNames.ProtectPermissionsPassword].Value = data.Properties["Owner password"].Value; } }
#pragma warning restore 618 #pragma warning disable 618 private void UpdateProtectAllowChangesProperties(PdfOperationsDesigner designer, Obsolete.Permissions oldPermissions) { Changes changes = Changes.None; if (oldPermissions.HasFlag(Obsolete.Permissions.AllowAssembly)) { changes = Changes.Assembly; } if (oldPermissions.HasFlag(Obsolete.Permissions.AllowFillIn)) { changes = Changes.FillIn; } if (oldPermissions.HasFlag(Obsolete.Permissions.AllowModifyAnnotations | Obsolete.Permissions.AllowFillIn)) { changes = Changes.AnnotateAndFillIn; } if (oldPermissions.HasFlag(Obsolete.Permissions.AllowModifyContents | Obsolete.Permissions.AllowModifyAnnotations | Obsolete.Permissions.AllowFillIn)) { changes = Changes.AnyExpectExtract; } designer.Properties[PropertyNames.ProtectAllowChanges].Value = changes; }
#pragma warning disable 618 private void UpdateProtectAllowPrintingProperties(PdfOperationsDesigner designer, Obsolete.Permissions oldPermissions) { Printing printing = Printing.None; if (oldPermissions.HasFlag(Obsolete.Permissions.AllowDegradedPrinting)) { printing = Printing.LowResolution; } if (oldPermissions.HasFlag(Obsolete.Permissions.AllowPrinting)) { printing = Printing.HighResolution; } designer.Properties[PropertyNames.ProtectAllowPrinting].Value = printing; }