Results 1 to 10 of 10

Thread: [RESOLVED] View Pdf file from Resource Or Added File

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Resolved [RESOLVED] View Pdf file from Resource Or Added File

    I'm trying to use a .pdf file I've added to my project but can't figure out how to get it to show using the webbrowser control. Here is what I'm using to call it:

    WebBrowser1.Navigate(Application.StartupPath.ToString + "\report.pdf")
    What is the correct way to do this?

    -Chris

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: View Pdf file from Resource Or Added File

    Do you have the file in the root path of the application ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: View Pdf file from Resource Or Added File

    Ok, I've finally got it to work correctly. Only problem is when I compile it now I get a /resources folder with the report.pdf inside and I don't like that, is there a way to embed the pdf inside the exe and still be able to view it using the code above?

    -Chris

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: View Pdf file from Resource Or Added File

    A resource file can be of this extensions.

    MSDN
    .rc
    .rct
    .res
    .resx
    .exe
    .dll
    .bmp, .ico, .dib, and .cur
    Please mark you thread resolved using the Thread Tools as shown

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: View Pdf file from Resource Or Added File

    Ok, well that sucks

    So is there a way to embed a .pdf document into a .net executable and be able to call it like I was?

    -Chris

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: View Pdf file from Resource Or Added File

    I don't think so..
    Please mark you thread resolved using the Thread Tools as shown

  7. #7
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: View Pdf file from Resource Or Added File

    You could embed the PDF in the EXE then extract it as a binary stream, copy it to a (temp) folder then read it from that folder. Would that work?
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: View Pdf file from Resource Or Added File

    That would work SJWhiteley if I knew how to do it

    I'm picking things up pretty slowly but not giving up...lol.

    -Chris

  9. #9
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: View Pdf file from Resource Or Added File

    The attached VS2008 project has an PDF resource which is saved to the Debug folder of the project and then loaded into a web browser on the calling form as suggested by SJWhiteley.

    If you are using VS2005 then the language extension can be used as a regular function be removing the extension tag.

    The PDF is a random file picked from my computer. Please note the code in form close which should be implemented too.
    Attached Files Attached Files

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: View Pdf file from Resource Or Added File

    Thanks Kevin!

    -Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width