Skip to Content
Former Member
Aug 26, 2010 at 02:33 PM

how to Merge multiple report documents to a single pdf?


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)


With HttpContext.Current.Response


.Buffer = True

.ContentType = "application/pdf"

.AddHeader("content-disposition", "attachment; filename=fname.pdf")

.OutputStream.Write(pdf.ToArray(), 0, pdf.length)


End With

Note: _rptDoc is a ReportDocument, tgrdShowEntry is a Radgrid