Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:21pm    
Why? <img src="..."/> will be more compact.
—SA
bobishkindaguy 19-Feb-13 19:02pm    
The document will be saved in a database, so it must be free of any file references.

Is this[^] what you are looking for?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:19pm    
Nice, a 5. (I suspect OP's question is simpler... who knows?)
—SA
Wonde Tadesse 19-Feb-13 20:36pm    
5+
bobishkindaguy 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.
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[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:20pm    
Sure it works, a 5.
—SA
Wonde Tadesse 19-Feb-13 20:36pm    
5+
bobishkindaguy 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ő 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900