ASP.net C# 用Aspose.pdf实现pdf合并

直接上代码,供参考,备忘!

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.Xml;

using System.IO;

using Aspose.Pdf;

public partial class gxcx_Default : System.Web.UI.Page

{

protected void dyall_Click(object sender, EventArgs e)

{

int x=0;

Document doc, doc1;

doc = new Document();

string djbh;

foreach (GridViewRow gvr in this.grid.Rows)

{

if (gvr.RowType == DataControlRowType.DataRow)

{

var cb1 = (CheckBox)gvr.FindControl("CheckBox1");

if (cb1.Checked == true)

{

djbh = gvr.Cells[0].Text;

if (!getpdf(djbh))

continue;

if(x==0)

{

doc= new Document(Server.MapPath("spd.pdf"));

x++;

}

else

{

doc1 = new Document(Server.MapPath("spd.pdf"));

doc.Pages.Add(doc1.Pages);

}

}

}

}

doc.Save(Server.MapPath("spd1.pdf"));

}

}

相关推荐
唐青枫6 分钟前
C#.NET ReaderWriterLockSlim 深入解析:读写锁原理、升级锁与使用边界
c#·.net
开开心心就好6 小时前
免费自媒体多功能工具箱,图片音视频处理
人工智能·pdf·ocr·excel·音视频·语音识别·媒体
ghie909010 小时前
C# WinForms 条形码生成器(含保存和打印预览功能)
开发语言·c#
蒙塔基的钢蛋儿10 小时前
告别内存泄露与空指针:用C#与.NET 10开启STM32H7高性能单片机开发新纪元
stm32·c#·.net
ZoeJoy810 小时前
C# Windows Forms 学生成绩管理器(StudentGradeManager)—— 方法重载、out、ref、params 参数示例
开发语言·c#
solicitous11 小时前
历史与术语
学习·c#
第二只羽毛11 小时前
第三章 栈,队列和数组
大数据·数据结构·c#
biuba102411 小时前
18 openclaw事务管理:确保数据一致性的最佳实践
开发语言·ai·c#·编程·技术
fengfuyao98511 小时前
C# 高仿QQ截图工具(支持自定义快捷键)
开发语言·c#
时光追逐者11 小时前
一款基于 .NET 开源、跨平台应用程序自动升级组件
c#·.net·.net core