上一篇博客说了我们公司项目里面用iTextsharp用于合并的一些情况和实例,那么当然有合并就得有切割,在切割上费了不少力气,下面是里面的部分代码,可以给大家参考一下。借鉴的依然是国外那个Wonderfulshare这家公司的PDF切割产品。
利用iTextsharp能很方便的获得PDF的相关属性,以下是相关代码。
try
{
properties = new Dictionary<string, string>();
fileSecurity = new Dictionary<string, string>();
properties.Add("Name", Info.Name);
properties.Add("Pdf version", Reader.PdfVersion.ToString());
properties.Add("Number of pages", Reader.NumberOfPages.ToString());
properties.Add("DirectoryName", Info.DirectoryName);
properties.Add("Length", Info.Length.ToString() + "(bytes)");
properties.Add("IsReadOnly", Info.IsReadOnly.ToString());
properties.Add("CreationTime", Info.CreationTime.ToString());
properties.Add("LastAccessTime", Info.LastAccessTime.ToString());
properties.Add("LastWriteTime", Info.LastWriteTime.ToString());
fileSecurity.Add("Is encrypted", Reader.IsEncrypted().ToString());
fileSecurity.Add("Is 128Key", Reader.Is128Key().ToString());
fileSecurity.Add("Full permissions", Reader.IsOpenedWithFullPermissions.ToString());
string sVal = PdfEncryptor.IsModifyAnnotationsAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Modify annotations", sVal);
sVal = PdfEncryptor.IsModifyContentsAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Modify content", sVal);
sVal = PdfEncryptor.IsPrintingAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Printing", sVal);
sVal = PdfEncryptor.IsScreenReadersAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Screen readers", sVal);
sVal = PdfEncryptor.IsDegradedPrintingAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Degraded printing", sVal);
sVal = PdfEncryptor.IsFillInAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Fill In", sVal);
sVal = PdfEncryptor.IsCopyAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Copy", sVal);
sVal = PdfEncryptor.IsAssemblyAllowed((int)Reader.Permissions) ? "Allowed" : "Not allowed";
fileSecurity.Add("Assembly", sVal);
result = Define.Success;
}
依旧要上借鉴的对方产品的图片