Load binary data into WebBrowser Control?

  • Thread starter Thread starter leslie eldrige
  • Start date Start date
L

leslie eldrige

Dear All,

I want to distribute just my EXE file without any document files or
settings. So I created a PDF document file and stored it into my resources.
The idea is to display it directly from main application using WebBrowser
control. I am using following snippet to reload my PDF document from
resources:

Dim myAssembly As Assembly = Assembly.GetExecutingAssembly()
Dim PdfResourceName As String = String.Format("{0}.{1}",
myAssembly.GetName().Name, "MyPdfFile.pdf")
Dim PdfStream As Stream =
myAssembly.GetManifestResourceStream(PdfResourceName)

Me.WebBrowser1.DocumentStream = PdfStream

The problem is that the WebBrowser control shows to me just binary data! I
am sure that I should also set the MIME Type to "application/pdf", but how I
can do it? The property "DocumentType" from WebBrowser is read only!

How can I set the MIME type by WEbBrowser or if it is not possible, then how
can I display my PDF file directly from resources without saving on the local
hard disk?

Thanks
 
Back
Top