直接上代码,供参考,备忘!
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"));
}
}