Multiple PDF's To Memory Stream
Posted on 2014-09-09
I am storing pdf files as blobs in a sql table. I want to combine those fields from multiple records to display one pdf in a web based application. The following code displays a pdf but it is always the pdf from the last record processed rather than all combined. I am assuming the loop is overwriting it each time but don't understand why ?
Dim ds As New DataSet
Dim intRpt As Integer
Dim strBranch As String
intRpt = 800
strBranch = "XXXXXX"
Dim dr As DataRow, rptname As String
ds = (DATASET RETURNED FROM CALLED PROCESS WHICH CONTAINS MULTIPLE RECORDS)
Dim bPages() As Byte, m As New MemoryStream, K As Long
For Each dr In ds.Tables("Status").Rows
bPages = dr("RPT")
K = UBound(bPages)
m.Write(bPages, 0, K)
rptname = "COMBINED.PDF"
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "inline; filename=" & rptname)
bPages = Nothing