Link to home
Start Free TrialLog in
Avatar of csbscott
csbscott

asked on

Multiple PDF's To Memory Stream

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)
        Next
        ds.Dispose()

        rptname = "COMBINED.PDF"
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-disposition", "inline; filename=" & rptname)
        Response.BinaryWrite(m.ToArray)

        m.Dispose()
        bPages = Nothing
        Response.End()
ASKER CERTIFIED SOLUTION
Avatar of BakuRetsu_X
BakuRetsu_X

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csbscott
csbscott

ASKER

Thanks !