Answered by:
PDF File Display store in Database

Question
-
Hi
I have Stored PDF file in a database i want to display this PDF file in my VB.net Window Form
How i display PDF in my Form..
Thanks & Regards
$Dev
spThursday, May 5, 2011 7:31 AM
Answers
-
Hi $Developer,
You need an OpenFileDialog control to browse to the file and a WebBrowser Control to display the .pdf file assuming that you have installed the Adobe Reader (Its must)
On Open File Button click event just write the code given below and the open file dialog will popup select the pdf file you want to view and webbrowser will open it for you
Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim filename As String With OpenFileDialog1 .Filter = "Adobe Files (*.pdf) |*.pdf" If .ShowDialog = Windows.Forms.DialogResult.OK Then filename = .FileName WebBrowser1.Url = New Uri(filename) End If End With End Sub End Class
On same button click event retrieve the value for the path you stored in the pdf file and assign it to the webbrowser instead of using the openfiledialog...
If you dont have a Adobe Reader installed still want to display a pdf file in VB.NET Windows Form go thoruh this link below :
http://www.codeproject.com/KB/applications/PDFViewerControl.aspx
The question if this solution doesnot work is how are you storing the file in database as BLOB or string path....?????
For string path it will surely work replace the openfiledialog with the path in database.... but for blob you need additional overhead of stream reading and writing....
Dont forget to mark it as answer if it solves your problem :
Thanks.
Roozan Parvez Bharucha MCT, MCITP (SQL Server 2008, Windows 7 Admin), MCTS (SQL Server 2008, Windows 7 Config, .NET Frmwk 3.5, .NET Frmwk 4.0 (Windows)), MCPD Enterprize App (Frmwk 3.5), MCPD Windows (Frmwk 4.0) CEO, RajAryanTech
- Proposed as answer by Rex Honour Thursday, May 5, 2011 9:24 AM
- Marked as answer by $Developer Thursday, May 5, 2011 10:30 AM
Thursday, May 5, 2011 9:23 AM
All replies
-
Hi $Developer,
You need an OpenFileDialog control to browse to the file and a WebBrowser Control to display the .pdf file assuming that you have installed the Adobe Reader (Its must)
On Open File Button click event just write the code given below and the open file dialog will popup select the pdf file you want to view and webbrowser will open it for you
Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim filename As String With OpenFileDialog1 .Filter = "Adobe Files (*.pdf) |*.pdf" If .ShowDialog = Windows.Forms.DialogResult.OK Then filename = .FileName WebBrowser1.Url = New Uri(filename) End If End With End Sub End Class
On same button click event retrieve the value for the path you stored in the pdf file and assign it to the webbrowser instead of using the openfiledialog...
If you dont have a Adobe Reader installed still want to display a pdf file in VB.NET Windows Form go thoruh this link below :
http://www.codeproject.com/KB/applications/PDFViewerControl.aspx
The question if this solution doesnot work is how are you storing the file in database as BLOB or string path....?????
For string path it will surely work replace the openfiledialog with the path in database.... but for blob you need additional overhead of stream reading and writing....
Dont forget to mark it as answer if it solves your problem :
Thanks.
Roozan Parvez Bharucha MCT, MCITP (SQL Server 2008, Windows 7 Admin), MCTS (SQL Server 2008, Windows 7 Config, .NET Frmwk 3.5, .NET Frmwk 4.0 (Windows)), MCPD Enterprize App (Frmwk 3.5), MCPD Windows (Frmwk 4.0) CEO, RajAryanTech
- Proposed as answer by Rex Honour Thursday, May 5, 2011 9:24 AM
- Marked as answer by $Developer Thursday, May 5, 2011 10:30 AM
Thursday, May 5, 2011 9:23 AM -
Hi,
How did you store the pdf files in database as filepath or as binary?
If you stored the path of the files then add a webbrowser control and by using its navigate function you can load the pdf.
webbroser1.navigate(filepath)
Regards, AnoopThursday, May 5, 2011 9:33 AM -
Thanks For Reply
But This is VB.net Window based application we cant use web browser control in my
application ..
Thanks
SDev
spThursday, May 5, 2011 12:01 PM -
Hi ,
In VB.NET there is a WebBrowserControl in the toolbox ofcourse we can use it in Window Based Applications.. Its easy rather or else go to my earlier post which you already have marked as an answer and try using the link by using Adobe Viewer Control but that will be a play around with the end user's system...
Thanks
Roozan Parvez Bharucha MCT, MCITP (SQL Server 2008, Windows 7 Admin), MCTS (SQL Server 2008, Windows 7 Config, .NET Frmwk 3.5, .NET Frmwk 4.0 (Windows)), MCPD Enterprize App (Frmwk 3.5), MCPD Windows (Frmwk 4.0) CEO, RajAryanTech- Proposed as answer by Rex Honour Thursday, May 5, 2011 12:22 PM
Thursday, May 5, 2011 12:21 PM -
Hi,
Actually, i stored pdf files into the database in binary format 'not path' and i want to show this pdf files directly from database without store into any directory on my windows form .
Please help me........
spFriday, May 6, 2011 6:56 AM -
System.Diagnostics.Process.Start("Acrobat.exe", "C:\Users\username\Desktop\New Details\file name.pdf")
use this one(work with adobe acrobat)
Thursday, June 2, 2011 9:32 AM -
hey dev,
can you please tell me how to store pdf files in data base using visual basic 6 codes??
Monday, August 8, 2011 9:13 AM -
hey dev,
can you please tell me how to store pdf files in data base using visual basic 6 codes??
I redirect to this thread for some solutions.
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9a5745d9-4fd7-44ba-b7fe-2a74a61f32c6
Martin Xie [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tuesday, August 9, 2011 6:29 AMModerator