Click here to Skip to main content
15,886,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends
I have a vb.net project to store PDF files in a sql server database
when I choose the file from device it displayed in adobe reader tool in the form,
once I click on save button the file is storing in DB as "
VarBinary
" and it's name displayed in the datagridview in the form.
I want to redisplay any pdf file when I double click on it's name in the datagridview

What I have tried:

this the code I use to store PDF files in DB:
Dim fs As New FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fs)
Dim Filepdf() As Byte = br.ReadBytes(br.BaseStream.Length)
cmd.Parameters.Add(New SqlParameter("@PDF_File", SqlDbType.VarBinary)).Value = Filepdf
Posted
Comments
Richard MacCutchan 8-Oct-20 12:45pm    
You just need to reverse that process. Extract the VarBinary data from the database and save it to disk. You can then pass it to the tool to display it.
adnan gharbi 8-Oct-20 13:05pm    
I don't want to save it to disk and pass it to the tool to display it
Imagine you have hundreds of pdf files and want to browse them one by one؟
Will I every time have to save the file in the device and then call it back to the tool ?? The process will be very stressful
I want to display it directly in the too
RedDk 8-Oct-20 13:22pm    
Absolutely!

What RmC says. What do you think you're going to do? Everytime you want to read one .pdf, you scroll to some point in the entire downloaded .pdf database and read there?
adnan gharbi 8-Oct-20 13:44pm    
I think I need some time to understand what you all said, or maybe I just couldn't get the idea right
To solve the problem:
Can someone write for me the code that displays the PDF file from the database in the adobe reader tool??
Richard MacCutchan 8-Oct-20 14:58pm    
Does the tool have the ability to read the data direct from a memory stream? The problem you have is finding a way to render the PDF in your form. Maybe take a look at The Leading PDF Platform for Developers | iText[^],

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900