using ComPDFKit.PDFDocument; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing { public class HomePageSetPasswordDialogModel { public bool CanOpen { get; set; } public bool CanEdit { get; set; } public static string PasswordForOpen = ""; public static string PasswordForEdit { get; set; } public enum PrintMod { None, LowDpi, HighDpi } public enum ChangeMod { None, ChangePage, FormAndSignature, AnnotAndFormAndSignature, ExceptAbstrat } public enum EnumNeedPassword { StatusNeedOpenPassword = 1 << 0, StatusNeedPermissionsPassword = 1 << 1 } public enum EnumPermissionsMod { StatusUnknown = 0, StatusRestrictPrinting = 1 << 0, StatusRestrictCopying = 1 << 1 } public static CPDFPermissionsInfo CreatePermissionsInfo(EnumPermissionsMod enumPermissionsMod) { CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo(); permissionsInfo.AllowsDocumentAssembly = true; permissionsInfo.AllowsDocumentChanges = true; permissionsInfo.AllowsPrinting = true; permissionsInfo.AllowsCopying = true; permissionsInfo.AllowsCommenting = true; permissionsInfo.AllowsFormFieldEntry = true; permissionsInfo.AllowsHighQualityPrinting = true; permissionsInfo.AllowsFormFieldEntry = true; if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictPrinting) > 0) { permissionsInfo.AllowsPrinting = false; permissionsInfo.AllowsHighQualityPrinting = false; } if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictCopying) > 0) { permissionsInfo.AllowsCopying = false; } return permissionsInfo; } /// ///生成带有指定权限的CPDFPermissionsInfo对象 /// public CPDFPermissionsInfo CreatePermissionsInfo(PrintMod printMod, ChangeMod changeMod) { CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo(); switch (printMod) { case PrintMod.None: permissionsInfo.AllowsPrinting = false; permissionsInfo.AllowsHighQualityPrinting = false; break; case PrintMod.LowDpi: permissionsInfo.AllowsPrinting = true; permissionsInfo.AllowsHighQualityPrinting = false; break; case PrintMod.HighDpi: permissionsInfo.AllowsHighQualityPrinting = true; permissionsInfo.AllowsPrinting = true; break; default: break; } switch (changeMod) { case ChangeMod.None: permissionsInfo.AllowsCopying = false; permissionsInfo.AllowsDocumentAssembly = false; permissionsInfo.AllowsCommenting = false; permissionsInfo.AllowsDocumentChanges = false; permissionsInfo.AllowsFormFieldEntry = false; break; case ChangeMod.ChangePage: permissionsInfo.AllowsCopying = false; permissionsInfo.AllowsDocumentAssembly = true; permissionsInfo.AllowsCommenting = false; permissionsInfo.AllowsDocumentChanges = false; permissionsInfo.AllowsFormFieldEntry = false; break; case ChangeMod.FormAndSignature: permissionsInfo.AllowsCopying = false; permissionsInfo.AllowsDocumentAssembly = false; permissionsInfo.AllowsCommenting = false; permissionsInfo.AllowsDocumentChanges = false; permissionsInfo.AllowsFormFieldEntry = true; break; case ChangeMod.AnnotAndFormAndSignature: permissionsInfo.AllowsCopying = false; permissionsInfo.AllowsDocumentAssembly = false; permissionsInfo.AllowsCommenting = true; permissionsInfo.AllowsDocumentChanges = false; permissionsInfo.AllowsFormFieldEntry = true; break; case ChangeMod.ExceptAbstrat: permissionsInfo.AllowsCopying = true; permissionsInfo.AllowsDocumentAssembly = true; permissionsInfo.AllowsCommenting = true; permissionsInfo.AllowsDocumentChanges = false; permissionsInfo.AllowsFormFieldEntry = true; break; } return permissionsInfo; } } }