none
How to open pdf file in vb.net applicatin?

Answers

  • Here is another way to read pdfs.

    Right click on any of the tabs in your toolbox and click choose items.(Just make sure you have a version of adobe reader installed before starting.) When the dialog box pops up click the 'com components' tab then pick tha 'adobe pdf reader' com component. Click ok and you should now see a 'adobe pdf reader' control in your toolbox. Click this and drag it to your vb form.(you may need to resize it, usually appears very small). Now in order to read any pdf just alter the 'src' property of the control either in code or in the designer. when you run the program you should be able to view the pdf doc in the vb form with most of the options you get in adobe reader. Here is how you would alter the 'src' property in code.

    Code Snippet

     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AdobeReader.src = "C:\mydoc.pdf"

    End Sub

     

    Hope this helps

    Matt

    Saturday, June 23, 2007 4:42 AM
  • The quick and easy way to do this is to use the web browser control. This assumes that both IE and the Acrobat Reader are installed on the target system. Just use the Navigate method of the control with the PDF filename as the parameter and you're there.
    Friday, June 22, 2007 7:37 PM

All replies

  • The quick and easy way to do this is to use the web browser control. This assumes that both IE and the Acrobat Reader are installed on the target system. Just use the Navigate method of the control with the PDF filename as the parameter and you're there.
    Friday, June 22, 2007 7:37 PM
  • Here is another way to read pdfs.

    Right click on any of the tabs in your toolbox and click choose items.(Just make sure you have a version of adobe reader installed before starting.) When the dialog box pops up click the 'com components' tab then pick tha 'adobe pdf reader' com component. Click ok and you should now see a 'adobe pdf reader' control in your toolbox. Click this and drag it to your vb form.(you may need to resize it, usually appears very small). Now in order to read any pdf just alter the 'src' property of the control either in code or in the designer. when you run the program you should be able to view the pdf doc in the vb form with most of the options you get in adobe reader. Here is how you would alter the 'src' property in code.

    Code Snippet

     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AdobeReader.src = "C:\mydoc.pdf"

    End Sub

     

    Hope this helps

    Matt

    Saturday, June 23, 2007 4:42 AM
  • I just tried to do this in an ASP.NET 2.0 application and after selecting Adobe PDF Reader from the COM components list, it came to the toolbox as disabled.  I don't seem to be able to drag it onto the project.

    Is there some other setup needed?  I do have adobe reader installed on my machine, and it comes up in a regular web browser whenever I load a pdf.  I've tried adding project references to the adobe dll's but this doesn't seem to make a difference either.

    Thanks in advance,
    Anye
    Friday, June 29, 2007 4:24 PM
  • Hi there Anye,

    the method i talked about earlier is for reading a pdf file within a vb.net windows application and not asp.net 2.0. To read a pdf in asp.net 2.0 just point a hyperlink straight to the pdf file and it should just open it within the browser no questions asked (provided you have adobe installed). Hope this helps

    Matthew

    Friday, July 06, 2007 7:17 AM
  •  

    I have the same question ... how to programatically (via code) open / display a .pdf file using VB.NET in the ASP.NET 2.0 environment. Thanks!
    Monday, August 27, 2007 10:15 PM
  • I attempted to load this file after following the steps you provided, and I get an error stating that AdobeReader is not declared. I am new to VB and do not know the proper steps to achieve viewing a .pdf file from a visual basic application. PLEASE HELP. THANK YOU

    Vince

    Tuesday, January 01, 2008 1:38 PM
  • Hi Matt

     

    When I am running @ the command prompt of window the pdf (or any extention of) file name , it search the respective program and run. I am using Powerbuilder 10, I need to know any API call that make me enable to do that with in the code (if i am going to mention the program name i.e. Run ("acrobat.exe profile.pdf")  it will run. But the problem is file could be text , jpg , bmp , or any user define file.....

     

    Thanks in Advance


    Rizvi

    Saturday, January 12, 2008 7:14 AM
  • hey Vince,
    'AdobeReader' was the name of the control that reads the pdf file. You dont have to call it 'AdobeReader' that's why it's being flagged as not declared. In the space of 'AdobeReader' put the name of the Adobe control that you drag from the tool box.
    Matt
    Monday, January 14, 2008 11:00 AM
  • Hey Matt,

     

    This is great.  But now I want to DEPLOY and the dang reader comes up blank when I run the program from an install of the .exe.  Do I need to do something special in by build do get the reader to deploy with the software? The form displays with a blank box where the reader should be, and when I invoke a pdf to load (click a button) I get nothing.

     

    Nettie

    Thursday, January 24, 2008 2:52 PM
  •  

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AdobeReader.src="C:\mydoc.pdf"

    End Sub

    THANKS A TON!  This worked like a dream!  Just remember to rename the adobe object to AdobeReader or replace AdobeReader with whatever name you selected.  I took this further with an OpenFileDialog and ended up just putting
    this in as my code:

    AdobeReader.src=openFileDialog1.FileName

    Now now to get the adobe object size to adjust to screen sizes.

    Thursday, July 10, 2008 2:28 PM
  • " Now now to get the adobe object size to adjust to screen sizes."

    Could you just set the dock to fill on the AdobeReader, and the make the window state maximized?
    asfd
    Saturday, August 23, 2008 2:59 PM
  • Private Sub frmMain_Resize(ByVal sender As System.Object, ByVal e as System.EventArgs) Handles Me.Resize
        pdfOutput.Size = Me.Size
    End Sub

    This is what I used when I resized my viewer.
    Wednesday, December 31, 2008 11:04 PM
  • When I follow your instructions and add the adobe control, it appears in the toolbox, but is greyed out.

    Am I missing something ? I have confirmed that the Acrobat reader is installed.
    Monday, January 19, 2009 7:49 PM
  • When I used the hyperlink method, I was prompted to Open or Save the PDF. Is there a way around this window ??

    Thanks,

     

    Oz

    Tuesday, January 27, 2009 3:27 PM
  • Is it possible to use this control in such a way that the PDF is saved in the resources folder or some other application folder? Can you open it from an self contained application folder rather than a folder on the user's computer?
    Sunday, April 26, 2009 9:05 PM
  • Use the following statment:

    System.Diagnostics.Process.Start(MyFile.pdf)

    Wednesday, September 29, 2010 4:01 PM
  • Hi MrChen,

    I tried this method but at runtime I get an exception stating that the class is not registered. Im using Visual Studio 2008. Plz help me 

     

    Sunday, November 28, 2010 1:06 PM
  • Thanks A Ton .. It Is really helpful.. it is working.. thank you so much Button event then add WebBrowser from the tool box.. Apply this coding on the button Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Process.Start("D:\book.pdf") ' Approach 1 WebBrowser1.Navigate("D:\book.pdf") ' Approach 2 AdobeReader.src = "D:\book.pdf" ' Approach 3: Add Reference to COM component: Adobe pdf Reader End Sub
    Tuesday, November 08, 2011 2:46 PM
  • I am also tryign this...tryign to add the Adobe PDF reader control...it comes in but its grayed out WHY?

    How do I endable the control in my toolbox?

     

    Monday, November 21, 2011 3:24 PM
  • Hi

    Is there any way to show the pdf documents in the windows forms application with out depending IE and the Acrobat Reader installed on the target system, because when the client machines gets updated either for the OS or Adobe Acrobat currently the application is not working as expected, so  I need to have this feature implementation with out using these two components IE and Acrobat Reader

    Regards,

    Chennas

    Wednesday, August 08, 2012 9:47 AM
  • This is great info but in VS2012 the Adobe PDF Reader control is grayed out and cannot be dragged over into an aspx or vb file.  Is there a way to enable it?

    Thanks in advance!

    Thursday, March 07, 2013 3:49 PM
  • Like many others have stated in this article the proposed solution does not work when the Adobe PDF Reader control is grayed out and cannot be dragged over into an aspx or vb file.  Is there a way to enable it?

    If you are providing a response that is supposed to be a solution to the initial post "How i can open pdf file in vb.net application" please address this particular item as it appears to be a very common problem for developers.


    SOTATS, Inc.

    Tuesday, September 17, 2013 2:59 PM
  • adobe pdf reader is not in COM components what can i do please help me
    Wednesday, June 25, 2014 7:21 AM
  • Hi Matt,

    I did what you mentioned above, but as I try to open my application in another PC it's not working, would you please let me know what should I do?

    Kind regards,

    Ehsan 

    Saturday, July 26, 2014 12:10 AM
  • Hi Matt,

    I did what you mentioned above, but as I try to open my application in another PC it's not working, would you please let me know what should I do?

    Kind regards,

    Ehsan 

    Ehsan Nikzad when you have a question, after reviewing a thread, then ask a new question in the forum. You can use the button in the toolbar at the top of an open question or post that looks like a paper clip and is in an area that is to the left of the letters HTML to provide a link to a post you want to reference in your question post.

    I would also recommend you learn what each of the buttons in the toolbar are for while you are editing a question post or a response post. As once your account is established you can add images to your post and other things.

    For now you may have to copy a link from your browsers tab and paste it into a post in order to reference the link to another post. As maybe that button that looks like a paper clip may not work for you until your account is established or verified or whatever Microsoft does with a new account. It took about 27 days before I could add an image to a post after my account was created.

    Also now that you have an account I would recommend you learn how to use your OneDrive so that you can upload things to the public folder, create a link to the public folder and copy and paste that link so others can access whatever is in your public folder. To test with that you can log onto your account, access the onedrive, upload things to the public folder and get a copy of a created link and paste it into notepad for example. Then logoff your account and use your browser with the link pasted in it to see if you can download from that account without being logged onto it. And in the future, as people do sometimes, you can zip a project folder, upload it to your public folder so others can download it to use it or troubleshoot issues with it if necessary.

    However a post this old may contain invalid information or something. Regardless earlier today I tried to navigate a webbrowser control to a .PDF file and all the webbrowser control displayed was a small square in the upper left corner. No .PDF file displayed even though my actual webbrowser (I.E. 11) apparently launches Adobe reader to display .PDF files. And the WebBrowser control is supposed to associate to whatever version of I.E. is installed on the system it is used on or something like that.

    Edit: Oh I forgot. Please read this link How to Use this Forum & FAQ (Read Before Making Your First Thread) as it gets old seeing people create question with "please help me" or "immediate help required" or some other junk in the subject line of the question that has nothing to do with the question. Nobody except a few microsoft employees gets paid to answer question on these forums. And the forums are not a Microsoft help line. Microsoft has paid assistance if an issue requires that.   

                                                       


    La vida loca




    Saturday, July 26, 2014 5:43 AM
  • This is the form.

     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            System.Diagnostics.Process.Start("C:\documents\PDF Book1.pdf")

      End Sub

    In my Project. Exe, when the button is clicked, the pdf or doc.book open in a normal PDF window, or a word window, or Power Point Window. but that if the application is running in my PC, In Other PC, the PDF Book doesn't open.

    Best regards

    Mouloud Berrhazi


    MdBi

    7 hours 54 minutes ago