I am trying to export multiple report documents to a single pdf. I did the below code but my pdf is getting overwritten with the latest report document.
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
Dim outstr() As MemoryStream = New MemoryStream(50) {}
Dim pdf As New MemoryStream
Dim byt() As Byte
For i as integer = 0 to tgrdShowEntry.SelectedItems.Count
outstr(i) = _rptDoc.ExportToStream(ExportFormatType.PortableDocFormat)
byt = outstr(i).ToArray()
pdf.Write(byt, 0, byt.Length)
Next
With HttpContext.Current.Response
.Clear()
.Buffer = True
.ContentType = "application/pdf"
.AddHeader("content-disposition", "attachment; filename=fname.pdf")
.OutputStream.Write(pdf.ToArray(), 0, pdf.length)
.End()
End With
Note: _rptDoc is a ReportDocument, tgrdShowEntry is a Radgrid