Export PDF file from Text field in Database

jdonaghe
jdonaghe used Ask the Experts™
on
I am trying to make an export program that will read the text field from a sql server 2000 database and restore the PDF data as a file on the hard drive.  I searched EE and the net and could not find examples of how to do this.  Please help.

Thanks,
     Jonathan Donaghe
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
The field in the database is not a varchar field, it is a "text" type.
what component/product you use to export to pdf?
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Most Valuable Expert 2012
Top Expert 2014

Commented:
There are a few options.

1) Use a product such as the bundled Crystal Reports to design the output, then you can export the report to PDF programmatically.
Example
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm

2) Use the iText open source library
http://www.ujihara.jp/iTextdotNET/en/

3) Use a third party commercial library
Example
http://www.syncfusion.com/products/reporting-edition/pdf?_kk=.net%20pdf&_kt=7af4674d-73fe-4a95-9fe0-9632ce9e1602&gclid=CKbt4ZD5zp8CFRhp4wodP3rtKg

Author

Commented:
Right now I don't use a product to export to pdf.  If is a commercial product that saves a scanned image into the field.  They also save the mime type in another field because the product will save other file types into the text field.
Most Valuable Expert 2012
Top Expert 2014

Commented:
How about the other approaches?
Commented:
I found out I just needed to create a filestream, extract the byte data using my default system encoding type and write it to a file on the harddrive.
Try
            Dim wFile As System.IO.FileStream
            Dim byteData() As Byte
            byteData = Encoding.Default.GetBytes(Dstblimgtext1.Tables(0).Rows(0)(6))
            wFile = New FileStream("C:\streamtest.pdf", FileMode.Append)
            wFile.Write(byteData, 0, byteData.Length)
            wFile.Close()
        Catch ex As IOException
            MsgBox(ex.ToString)
End Try

Open in new window

Most Valuable Expert 2012
Top Expert 2014

Commented:
The question was really misleading in that you said the DB field is "TEXT" and you failed to describe that its the bytes of the PDF file which are actually stored in the DB.

Author

Commented:
I'm sorry you were confused, but I didn't know the format it was stored in.  I was looking for ways to export either binary, text, etc.  I was trying to see if anyone else ran into this specific problem before.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial