Solved

Multiple PDF's To Memory Stream

Posted on 2014-09-09
2
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
BakuRetsu_X earned 500 total points
ID: 40313019
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
ID: 40319308
Thanks !
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

726 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