private void btnSplit_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtSource.Text)) { MessageBox.Show("请选择文件"); } int pageSize = int.Parse(txtPageSize.Text); PDFFactory pf = new PDFFactory(); pf.Splite(txtSource.Text, pageSize); MessageBox.Show("拆分文件成功"); } catch { MessageBox.Show("拆分文件失败"); } }
private void btnUnlock_Click(object sender, EventArgs e) { try { PDFFactory pf = new PDFFactory(); foreach (ListViewItem li in lvItems.Items) { OperateItem sf = li.Tag as OperateItem; if (sf != null) { pf.AddDocument(sf.FileName,"123456"); } } pf.Merge(txtTarget.Text); MessageBox.Show("合并文件成功!"); } catch { MessageBox.Show("合并文件失败"); } }
private void btnMerge_Click(object sender, EventArgs e) { try { PDFFactory pf = new PDFFactory(); foreach (ListViewItem li in lvItems.Items) { OperateItem sf = li.Tag as OperateItem; if (sf != null) { pf.AddDocument(sf.FileName, sf.StartPage, sf.EndPage); } } pf.Merge(txtTarget.Text); MessageBox.Show("合并文件成功!"); } catch(iTextSharp.text.pdf.BadPasswordException ex) { MessageBox.Show("合并文件失败" + ex.Message); } }