Solved

Multiple PDF's To Memory Stream

Posted on 2014-09-09
2
157 Views
Last Modified: 2014-09-12
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()
0
Comment
Question by:csbscott
2 Comments
 
LVL 2

Accepted Solution

by:
BakuRetsu_X earned 500 total points
Comment Utility
If they are different byte array files in each of those rows, you won't be able to combine pdf files that way.  You will need an API to merge the pdf files together, then you can display it.  Something like PdfSharp will do what you  are looking for.
0
 

Author Closing Comment

by:csbscott
Comment Utility
Thanks !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...)) The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now