Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Display Assembly Resources in Web Browser (problem with jpg/pdf)

Display Assembly Resources in Web Browser (problem with jpg/pdf)

Scheduled Pinned Locked Moved C#
helphtmldatabasequestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sodevrom
    wrote on last edited by
    #1

    Hello, I have 3 types of resources embeded in my executable : html, jpg and pdf. I also have a listbox, and I want whenever a user sleects a different item, to display it in a web browser. I have no problems doing that to HTML files, but with the other one, it's a different thing and I hope someone can help me do this. First, I want to say that I don't want to save the resources locally and after that load them in the browser, because I don't want users to see them. I am using this to view the html : Assembly assembly = Assembly.GetExecutingAssembly(); webBrowser1.DocumentStream = assembly.GetManifestResourceStream("ebook.index.html"); If I try to do the same thing to the pdf or jpg, it simply shows me the binary data of the files, it does not display them in the browser. Is it possible to make the visible in the browser, directly from the assembly ? What are my options ? Thank you

    L 1 Reply Last reply
    0
    • S sodevrom

      Hello, I have 3 types of resources embeded in my executable : html, jpg and pdf. I also have a listbox, and I want whenever a user sleects a different item, to display it in a web browser. I have no problems doing that to HTML files, but with the other one, it's a different thing and I hope someone can help me do this. First, I want to say that I don't want to save the resources locally and after that load them in the browser, because I don't want users to see them. I am using this to view the html : Assembly assembly = Assembly.GetExecutingAssembly(); webBrowser1.DocumentStream = assembly.GetManifestResourceStream("ebook.index.html"); If I try to do the same thing to the pdf or jpg, it simply shows me the binary data of the files, it does not display them in the browser. Is it possible to make the visible in the browser, directly from the assembly ? What are my options ? Thank you

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I haven't done this myself, but the way I understand it you must also set the WebBrowser.DocumentType (try "application/pdf"); that should allow you to view a PDF document (or any image) as a web page. You probably also want images inside web pages, so have a look at embedded images[^]. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, I haven't done this myself, but the way I understand it you must also set the WebBrowser.DocumentType (try "application/pdf"); that should allow you to view a PDF document (or any image) as a web page. You probably also want images inside web pages, so have a look at embedded images[^]. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        S Offline
        S Offline
        sodevrom
        wrote on last edited by
        #3

        Hello, Thank you for the quick reply but unfortunatly the DocumentType is read only :( Any other ideeas ? Thanx

        L 2 Replies Last reply
        0
        • S sodevrom

          Hello, Thank you for the quick reply but unfortunatly the DocumentType is read only :( Any other ideeas ? Thanx

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Yes, you are right. And the data scheme[^] is usable only for small amounts of data, hence small images only, no PDF documents. I guess the next logical approach is to come up with a simple HTTP server that can provide HTML and PDF; then embed that in the app, andmake the WebBrowser navigate to it. This seems to be a candidate: Sample HTTP Server Skeleton in C#[^] :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          1 Reply Last reply
          0
          • S sodevrom

            Hello, Thank you for the quick reply but unfortunatly the DocumentType is read only :( Any other ideeas ? Thanx

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi, I now have a simple embedded HTTP server working based on the article I provided a link to. It gets a PDF document somewhere (from a file!), then serves that to its client, which can be either a regular browser (e.g. FireFox) or a WebBrowser. It still needs a lot of clean-up though, but I wanted to confirm you can make it work. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            S 1 Reply Last reply
            0
            • L Luc Pattyn

              Hi, I now have a simple embedded HTTP server working based on the article I provided a link to. It gets a PDF document somewhere (from a file!), then serves that to its client, which can be either a regular browser (e.g. FireFox) or a WebBrowser. It still needs a lot of clean-up though, but I wanted to confirm you can make it work. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


              S Offline
              S Offline
              sodevrom
              wrote on last edited by
              #6

              Thank you very much for your help

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups