We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I store and retrieve the PDF document from the DataBase?

 

Essential Pdf does provide support for reading and writing Pdf documents from or to the System.IO.Stream. We can store this pdf document stream in to the database as binary object in the database.

C#

// Store the PDF document in DataBase

//Initialize a stream

MemoryStream stream = new MemoryStream();

// Save the document to stream

doc.Save(stream);

// Retrieve and display the stream in PDFformat

OleDbDataReader Reader = command.ExecuteReader();

 byte[] PdfFile = (byte[]) Reader[1];

Stream strm = new MemoryStream(PdfFile);

using (FileStream fstream = new FileStream("sample.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite))

{

fstream.Write(PdfFile, 0, PdfFile.Length);

}

VB

' Store the PDF document in DataBase

'Initialize a stream

Dim stream As MemoryStream = New MemoryStream()

' Save the document to stream

doc.Save(stream)

' Retrieve and display the stream in PDFformat

Dim Reader As OleDbDataReader = command.ExecuteReader()

Dim PdfFile As Byte() = CType(Reader(1), Byte())

Dim strm As Stream = New MemoryStream(PdfFile)

Using fstream As FileStream = New FileStream("sample.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite)

fstream.Write(PdfFile, 0, PdfFile.Length)

End Using

Please do find the sample from the below specified location,

http://www.syncfusion.com/support/user/uploads/PdfDataBaseDemo_f1a61b02.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
889 04/30/2011 07/10/2014 Windows Forms PDF
Tags:
Did you find this information helpful?
Comments
tomer Dec 23, 2016
1.Link to demo is broken
2.code for saving the pdf is missing
2.The type of column in the db table is not specified

Reply
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.