Click here to Skip to main content
11,505,486 members (58,481 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET4
We need to embed an image in an html document, in C# or VB code. The document will be saved in a database, so it must be free of any file references. I have been researching this for a day or so, and cannot find anything complete. I would like to know if anyone has a step by step process for doing this.
Posted 19-Feb-13 11:43am
Comments
Sergey Alexandrovich Kryukov at 19-Feb-13 18:21pm
   
Why? <img src="..."/> will be more compact.
—SA
BobishKindaGuy at 19-Feb-13 19:02pm
   
The document will be saved in a database, so it must be free of any file references.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Is this[^] what you are looking for?
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 19-Feb-13 18:19pm
   
Nice, a 5. (I suspect OP's question is simpler... who knows?)
—SA
Wonde Tadesse at 19-Feb-13 20:36pm
   
5+
BobishKindaGuy at 19-Feb-13 21:40pm
   
Thanks Marcus, your suggestion goes to a page that works, but with a tool.
I found Zoltán's reference, located some base64 encoder code, (http://www.codeproject.com/Articles/5483/Base64-Encoder-Decoder-in-C), and converted it to VB. So far I can save the html doc in a database field and retrieve it, whereupon it appears as an image, so I think with a few more tweaks I'll be fine. Next task will be attachments, same goal.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

There is a way, by using base64 encoding, see this article: http://www.bigfastblog.com/embed-base64-encoded-images-inline-in-html[^]
But I am not sure if there is any size limit, or what is the browser support coverage.

What you might also consider is storing mht's which are also self-contained. A starting point ó could be this article: http://mycsharpcorner.blogspot.hu/2011/01/create-mht-from-html-in-c.html[^]
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 19-Feb-13 18:20pm
   
Sure it works, a 5.
—SA
Wonde Tadesse at 19-Feb-13 20:36pm
   
5+
BobishKindaGuy at 19-Feb-13 21:42pm
   
Thanks Zoltán!
I located some base64 encoder code, (http://www.codeproject.com/Articles/5483/Base64-Encoder-Decoder-in-C), and converted it to VB. So far I can save the html doc in a database field and retrieve it, whereupon it appears as an image, so I think with a few more tweaks I'll be fine. Next task will be attachments, same goal.
Zoltán Zörgő at 20-Feb-13 3:25am
   
If you need attachments too, I suggest you switch to something else, like mht or pdf. You need a self-contained document format, html is not one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 512
1 F-ES Sitecore 380
2 Richard Deeming 270
3 CHill60 245
4 Richard MacCutchan 230
0 Sergey Alexandrovich Kryukov 1,067
1 Maciej Los 575
2 Peter Leow 540
3 F-ES Sitecore 525
4 DamithSL 470


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100