Load varbinary data from SQL server and show pdf files on ASP .Net

Hi,

There is one table that stores PDF file information (filename varchar, filecontent varbinary(max), ID int, Desc varchar, StudyCodeID int). My Asp project will select some filecontent and show them as PDF files. I can create a PDF file (many pages based on records user selected) to hold all pages. The text in each page of the PDF is correct, but the format is not as the original PDF format that I saved in the data table (misses underline and bold). See the code below:

Protected Function ConcatenatePDFListTest(ByVal PDFList As SortedList) As MemoryStream

    Dim inputStreams(PDFList.Count + 1) As MemoryStream
    Dim streamCounter As Integer = 1

    ' push each, separate PDF stream into the array of streams
    For Each sTSCode As String In PDFList.Keys
        ' concatenate all TS Code PDF streams into one PDF stream
        If Not PDFList(sTSCode) Is Nothing Then
            ' Instantiate Pdf object by calling its empty constructor
            Dim pdf1 As New Aspose.Pdf.Generator.Pdf()

            ' Create a new section in the Pdf object
            Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()

            ' Create a new text paragraph and pass the text to its constructor as argument
            Dim pdfDocument As New Document(DirectCast(PDFList(sTSCode), MemoryStream))
            Dim textAbsorber As New TextAbsorber()
            pdfDocument.Pages.Accept(textAbsorber)

            Dim extractedText As String = textAbsorber.Text

            ' Add time study code description to pdf
            Dim t As New Aspose.Pdf.Generator.Text(extractedText)
            sec1.Paragraphs.Add(t)

            ' pdf1.Save("test.Pdf")

            inputStreams(streamCounter) = New MemoryStream()
            pdf1.Save(inputStreams(streamCounter))
            streamCounter += 1
        End If
    Next

    ' add first page
    Dim PDFBodyStream As MemoryStream = New MemoryStream()

    ' get list of TS definitions
    Dim pdfDocBody As New Aspose.Pdf.Document()
    ' Return the stream of TS definitions
    pdfDocBody.Save(PDFBodyStream)
    inputStreams(0) = PDFBodyStream

    Dim finalStream As New MemoryStream()
    Dim pdfEditor As New Aspose.Pdf.Facades.PdfFileEditor()
    pdfEditor.Concatenate(inputStreams, finalStream)

    ' final format ready to display
    Return finalStream
End Function

Hi Bob,


Please follow the approach specified over 439636. In the event of any further query, please feel free to contact.

PS, Please note that Aspose.Pdf for .NET does not directly support the feature to display/view the PDF documents. However, our sister company GroupDocs.com offers a viewer app which you may consider including in your application to view the PDF files.