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

Hi,

Thereis one table that store 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 that base on records user selected) to hold all pages. The text in each page of pdf is correct but the formate is not as the original pdf formate that I saved in data table(miss under line and bold). See code below:

ProtectedFunction ConcatenatePDFListTest(ByVal PDFList As SortedList) As MemoryStream<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim
inputStreams(PDFList.Count + 1) As MemoryStream
<o:p></o:p>

Dim
streamCounter As Integer
= 1
<o:p></o:p>

’ push each, separate PDF stream into the array of streams<o:p></o:p>

For
Each sTSCode As
String In
PDFList.Keys
<o:p></o:p>

’ concatenate all TS Code PDF streams into one PDF stream<o:p></o:p>

If
Not PDFList(sTSCode) Is
Nothing Then
<o:p></o:p>

'Instantiate Pdf pbject by calling its empty constructor<o:p></o:p>

Dim
pdf1 As Aspose.Pdf.Generator.Pdf = New
Aspose.Pdf.Generator.Pdf()
<o:p></o:p>

'Create a new section in the Pdf object<o:p></o:p>

Dim
sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
<o:p></o:p>

''Create a new text paragraph and pass the text to its constructor
as argument
<o:p></o:p>

Dim
pdfDocument As New
Document(DirectCast(PDFList(sTSCode),
MemoryStream))
<o:p></o:p>

Dim
textAbsorber As New
TextAbsorber()
<o:p></o:p>

pdfDocument.Pages.Accept(textAbsorber)<o:p></o:p>

Dim
extractedText As String
= textAbsorber.Text
<o:p></o:p>

'Add time study code description to pdf<o:p></o:p>

Dim
t As New
Aspose.Pdf.Generator.Text(extractedText)
<o:p></o:p>

sec1.Paragraphs.Add(t)<o:p></o:p>

'pdf1.Save(“test.Pdf”)<o:p></o:p>

inputStreams(streamCounter)
= <o:p></o:p>

New
MemoryStream()
<o:p></o:p>

pdf1.Save(inputStreams(streamCounter))<o:p></o:p>

streamCounter
+= 1<o:p></o:p>

End
If
<o:p></o:p>

Next<o:p></o:p>

’ add first page<o:p></o:p>

Dim
PDFBodyStream As MemoryStream
= New MemoryStream
<o:p></o:p>

’ get list of TS definitions<o:p></o:p>

Dim
pdfDocBody As Aspose.Pdf.Document = New
Aspose.Pdf.Document()
<o:p></o:p>

’ Return the stream of TS definitions<o:p></o:p>

pdfDocBody.Save(PDFBodyStream)<o:p></o:p>

inputStreams(0)
= PDFBodyStream<o:p></o:p>

Dim
finalStream As New
MemoryStream
<o:p></o:p>

Dim
pdfEditor As Aspose.Pdf.Facades.PdfFileEditor = New
Aspose.Pdf.Facades.PdfFileEditor()
<o:p></o:p>

pdfEditor.Concatenate(inputStreams,
finalStream)<o:p></o:p>

’ final format ready to display<o:p></o:p>

Return
finalStream
<o:p></o:p>

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.