I am not sure it is the appropriate place to put my question. However, I want to save the contents of a <div> element to an image. It is more or less like a screen shot, but only covers the area inside particular div. Can any one help me in it.
Thanks,
Zeeshan Umar ~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
Thanks for reply, but these articles are related to exporting Text as image. I want a screen capture utility thrugh which i can capture all the content of a div as they are appearing on my browser.
Thanks,
Zeeshan Umar ~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
sirdneo
All-Star
15171 Points
2509 Posts
Save Contents of a <div> as an Image
Jul 06, 2009 07:47 AM|LINK
I am not sure it is the appropriate place to put my question. However, I want to save the contents of a <div> element to an image. It is more or less like a screen shot, but only covers the area inside particular div. Can any one help me in it.
Zeeshan Umar
~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
chintanpshah
All-Star
19058 Points
3273 Posts
Re: Save Contents of a <div> as an Image
Jul 06, 2009 09:57 AM|LINK
Refer to:
http://www.codeproject.com/KB/web-image/TextOnImage.aspx
http://chiragrdarji.wordpress.com/2008/05/09/generate-image-from-text-using-c-or-convert-text-in-to-image-using-c/
http://weblogs.asp.net/yaneshtyagi/archive/2008/11/07/text-to-image-convertor.aspx
http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-how-to-draw-text-on-an-image
http://dotnet-snippets.com/dns/draw-text-on-image-SID596.aspx
My Software Website
sirdneo
All-Star
15171 Points
2509 Posts
Re: Save Contents of a <div> as an Image
Jul 06, 2009 12:09 PM|LINK
Thanks for reply, but these articles are related to exporting Text as image. I want a screen capture utility thrugh which i can capture all the content of a div as they are appearing on my browser.
Zeeshan Umar
~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
chintanpshah
All-Star
19058 Points
3273 Posts
Re: Save Contents of a <div> as an Image
Jul 06, 2009 02:27 PM|LINK
Use free service provided by http://www.thumbshots.org/.
Create a new page and give the URL of that page in which there is only one DIV with you content.
My Software Website
Ram Reddy Me...
Star
9604 Points
1314 Posts
Re: Save Contents of a <div> as an Image
Jul 06, 2009 03:31 PM|LINK
Do this...
<div id="painter" runat="server" style="left: 280px; position: absolute; top: 82px;
width: 311px; height: 388px; background-color: #ccccff;">
</div>
<asp:Button ID="Button1" runat="server" Style="left: 733px; position: absolute; top: 266px"
Text="Button" OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
string[] value = painter.Style.Value.Split(';');
string width = value[3];
string height = value[4];
string bgcolor = value[5];
string[] widthArray = width.Split(':');
string[] heightArray = height.Split(':');
string[] bgcolorArray = bgcolor.Split(':');
int w = int.Parse(widthArray[1].Replace("px", ""));
int h = int.Parse(heightArray[1].Replace("px",""));
string color = bgcolorArray[1];
System.Drawing.Color c = System.Drawing.Color.FromName("#ccccff");
System.Drawing.Bitmap bt = new System.Drawing.Bitmap(w, h);
System.Drawing.Graphics oGraphics = System.Drawing.Graphics.FromImage(bt);
System.Drawing.Brush brush = new System.Drawing.SolidBrush(k);
oGraphics.FillRectangle(brush, 0, 0, w, h);
bt.Save("D:\\abc.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
Abhiram Reddy Mekha
sirdneo
All-Star
15171 Points
2509 Posts
Re: Save Contents of a <div> as an Image
Jul 07, 2009 03:56 AM|LINK
THanks for reply, but i want a generalized way to capture my web page's div. I am looking something similar to FireShot.
Zeeshan Umar
~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
RamiShareef
Member
2 Points
6 Posts
Re: Save Contents of a <div> as an Image
Dec 09, 2009 12:02 PM|LINK
@Ram
and what if this div had controls inside, how could I re-draw them all inside the image ??
Thank you.
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Save Contents of a <div> as an Image
Dec 10, 2009 11:35 AM|LINK
> I want a screen capture utility thrugh which i can capture all the content of a div as they are appearing on my browser.
For a screen capture utility try GADWIN Web SnapShot and PrintScreen from http://www.gadwin.com/download/
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
dardanus
Member
2 Points
2 Posts
Re: Save Contents of a <div> as an Image
Nov 24, 2012 04:16 PM|LINK
Hi! Have you found any solution?? I have the same problem, could you help me?
thnx