123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using ComPDFKit.PDFDocument;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Master.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;
- }
- ///<returns>
- ///生成带有指定权限的CPDFPermissionsInfo对象
- ///</returns>
- 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;
- }
- }
- }
|