Solved

Multiple PDF's To Memory Stream

Posted on 2014-09-09
2
162 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
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…

810 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