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"));

}

}

相关推荐
yangshuquan5 分钟前
C# 委托和事件的3点区别,你知道几个?
c#·委托·事件·编程技巧
她说彩礼65万5 小时前
C# Lambda 表达式
开发语言·c#
烛阴6 小时前
C#常量(const)与枚举(enum)使用指南
前端·c#
阿Y加油吧7 小时前
java并发编程面试题精讲——day02
java·面试·c#
唐青枫8 小时前
C#.NET DateTime 最强入门到进阶:格式化、转换、UTC、时区全覆盖
c#·.net
葛小白11 天前
C#进阶13:C#全局路径规划算法_A*
c#·路径规划算法·astar算法
拓端研究室1 天前
专题:2025年AI Agent智能体行业价值及应用分析报告:技术落地与风险治理|附140+ 份报告PDF、数据、可视化模板汇总下载
人工智能·pdf
时光追逐者1 天前
C#/.NET/.NET Core技术前沿周刊 | 第 61 期(2025年11.10-11.16)
c#·.net·.netcore