[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:
Quote:
WebBrowser1.Navigate(Application.StartupPath.ToString + "\report.pdf")
What is the correct way to do this?
-Chris
Re: View Pdf file from Resource Or Added File
Do you have the file in the root path of the application ?
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
Re: View Pdf file from Resource Or Added File
A resource file can be of this extensions.
MSDN
Quote:
.rc
.rct
.res
.resx
.exe
.dll
.bmp, .ico, .dib, and .cur
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
Re: View Pdf file from Resource Or Added File
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?
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
1 Attachment(s)
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.
Re: View Pdf file from Resource Or Added File