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

}

}

相关推荐
SunnyDays10114 分钟前
使用 C# 将 Excel XLSX 或 XLS 转换为 HTML:完整指南
c#·excel转html·xlsx转html·xls转html
时光追逐者4 分钟前
一款基于 .NET Avalonia 开源免费、快速、跨平台的图片查看器
c#·.net·图片查看器
小咖自动剪辑1 小时前
小学数学题混合生成器:一键定制PDF练习题/试卷
pdf
阿蒙Amon14 小时前
C#每日面试题-Thread.Sleep和Task.Delay的区别
java·数据库·c#
cfqq198915 小时前
Settings,变量保存
开发语言·c#
云草桑16 小时前
.net AI开发04 第八章 引入RAG知识库与文档管理核心能力及事件总线
数据库·人工智能·microsoft·c#·asp.net·.net·rag
曹牧18 小时前
C#:窗体构造函数无法引用窗体控件
开发语言·c#
iAkuya18 小时前
(leetcode)力扣100 54实现Trie树
算法·leetcode·c#
xb113218 小时前
C#使用Cancellation来取消异步任务
开发语言·c#
m0_7482299918 小时前
C与C#:编程语言的核心差异解析
c语言·开发语言·c#