?
Solved

Multiple PDF's To Memory Stream

Posted on 2014-09-09
2
Medium Priority
?
167 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 2000 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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…
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.

770 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