0
Answer

How to export multiple report document to single pdf

raj arokia

raj arokia

15y
6.5k
1

I am trying to export different report documents to a single pdf . i did the below code but my pdf is getting overwritten with the latest report document.
inCode:
 i have exported the report document of type pdf  as bytes in memory stream array, and then storing the byte array to the pdf memory stream
 
byte[] byt;
MemoryStream[] outstr = new MemoryStream[reportDocument.Length];
MemoryStream pdf;

 
for
(i = 0; i < reportDocument.Length; i++)
{

outstr[i] = (
MemoryStream)reportDocument[i].ExportToStream(ExportFormatType.PortableDocFormat);
byt = outstr[i].ToArray();
pdf.Write(byt, 0, byt.Length);

}
Response.Clear();
Response.Buffer =
true;
Response.ContentType =
"application/pdf";
Response.BinaryWrite(pdf.ToArray());
Response.End();