iTextsharp.dll用于分割的实战实例

上一篇博客说了我们公司项目里面用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;
            }

依旧要上借鉴的对方产品的图片


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值