动态数组赋值

OTTO的OTTO 2010-04-13 09:07:34
现在利用aspose合并pdf文件
 for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
//.....
string inFile = Server.MapPath("../Report/RT_MT_print.pdf");
string outFile = Server.MapPath("../connection/dataTemp/output" + repName + ".pdf");

Form form = new Form(inFile, outFile);

//......
form.Save();
}
通过循环生成一系列编号的pdf文件,怎样将这些文件合并成一个pdf文件?
一下是aspose合并文件的代码:
//Create input stream objects holding the PDF files to be concatenated

FileStream inStream1 = new FileStream(".\\example1.pdf", FileMode.Open);

FileStream inStream2 = new FileStream(".\\example2.pdf", FileMode.Open);

FileStream inStream3 = new FileStream(".\\example3.pdf", FileMode.Open);

FileStream inStream4 = new FileStream(".\\example4.pdf", FileMode.Open);



//Create output stream object that would contain the final PDF file

FileStream outStream = new FileStream(".\\multiStream.pdf", FileMode.Create);



//Store all input streams in an Array

Stream[] inStreams = new Stream[] { inStream1, inStream2, inStream3, inStream4 };



//Instantiate PdfFileEditor object

PdfFileEditor pdfEditor = new PdfFileEditor();



//Call Concatenate method of PdfFileEditor object to concatenate all input streams into a single output stream

pdfEditor.Concatenate(inStreams, outStream);



//Finally close the output stream

outStream.Close();


难点就是给new Stream[]赋值。。。。。。。。。。请大侠帮助~~












...全文
446 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lee_b 2010-04-14
  • 打赏
  • 举报
回复
搞定就好,接点分。。
OTTO的OTTO 2010-04-14
  • 打赏
  • 举报
回复
已经解决,利用循环赋值,搞定的。

 starr[j] = Server.MapPath("../connection/dataTemp/print" + repName + ".pdf");
inSteam[j] = new FileStream(starr[j],FileMode.Open);
inSteams[j] = inSteam[j];
初吻给了烟 2010-04-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 foxdave 的回复:]
C# code
List<Stream> streams = new List<Stream>();
[/Quote]

楼上正解 用泛型直接添加Stream
取出时也不用强制类型转换....
Justin-Liu 2010-04-13
  • 打赏
  • 举报
回复
List<Stream> streams = new List<Stream>();

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧