citronas
citronas

Reputation: 19365

Load an embedded html file into a webrowser control and replace img tags to point to embedded images

I want to show a html document in a web browser control (WinForms). The html file should contain images, that are embedded resources.

How can I modify the html that is shown in the webbrowser to replace the src attribute of the img tags to somehow show the embedded resource without copying it into the file system?

Upvotes: 1

Views: 1171

Answers (2)

Arman
Arman

Reputation: 419

As you know Data URI's have problem with older browsers (IE < 8) so :

  1. You can use MHTML manner to save your embedding images.

  2. You can make Data URI's with this kind of javascript.

Upvotes: 1

Mike Miller
Mike Miller

Reputation: 16575

You could use src="data:image/png;base64,.... and replace the .... with the base64 encoded string.

You'll need to replace the src="url" for the img tags in the given HTML, which means you would have to store the HTML somewhere on disk temporarily, so I guess doesn't solve the problem, unless you have access to the HTML.

Upvotes: 2

Related Questions