1. in asp.net application, i will draw certain shapes (rectangle,elipse etc). using basic html such as table,td tr, <p> etc. ..so basicaly a html deigner in broswer on client side.
2. i will also type some text in <P> tags ...
3. will set fonts , style using using css.
all this will happen in browser just like a basic html editor after that i will post asp.net page back to server. onserver side i want to convert the HTML view that i was seeing in the browser into an image.
a)can some one please suggest how to do this in .net .40 or 3.0 ?
b)are there any third part components that can do this. are these third party components multithreaded and scalable?
here is one ...that seem to do it ..not used it yet..
There are a few services out there that serve up screenshots of any webpage for you to display on your website. One popular one is
Kwiboo; this is the one that
DotNetKicks uses. For some time now I've wondered what the easiest way to do this in .NET was, and today I stumbled upon the undocumented WebBrowser.DrawToBitmap method that makes this extremely easy to do.
Here's a sample method that returns a Bitmap representation of a webpage:
public Bitmap GenerateScreenshot(string url) { // This method gets a screenshot of the webpage // rendered at its full size (height and width) return GenerateScreenshot(url, -1, -1); }
public Bitmap GenerateScreenshot(string url, int width, int height) { // Load the webpage into a WebBrowser control WebBrowser wb = new WebBrowser(); wb.ScrollBarsEnabled = false; wb.ScriptErrorsSuppressed = true; wb.Navigate(url); while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
// Set the size of the WebBrowser control wb.Width = width; wb.Height = height;
if (width == -1) { // Take Screenshot of the web pages full width wb.Width = wb.Document.Body.ScrollRectangle.Width; }
if (height == -1) { // Take Screenshot of the web pages full height wb.Height = wb.Document.Body.ScrollRectangle.Height; }
// Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control Bitmap bitmap = new Bitmap(wb.Width, wb.Height); wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height)); wb.Dispose();
return bitmap; }
<div class="content">
Here are some example usages of the above method:
// Generate thumbnail of a webpage at 1024x768 resolution Bitmap thumbnail = GenerateScreenshot("http://pietschsoft.com", 1024, 768);
// Generate thumbnail of a webpage at the webpage's full size (height and width) thumbnail = GenerateScreenshot("http://pietschsoft.com");
// Display Thumbnail in PictureBox control pictureBox1.Image = thumbnail;
/* // Save Thumbnail to a File thumbnail.Save("thumbnail.png", System.Drawing.Imaging.ImageFormat.Png); */
Thanks however what i m trying to do is some what different...
i do not want to make request to a web page and convert the out put into image....instead i need to do following..
belwo is the exact sequence...may be it was unclear in my earlier post..
1. use will request may asp.net web page in browser.
2. he will use the html editor on this page to create some html layout.
3.he will hit 'save to image' button on this page. clicking on this button will do a post back to the server.
4. now the server side in code behind,upon post back, i want to collect what was the view in browser before user hit 'save to image' button and convert that view into image....
is this possible...it is different than requesting a URL using a webrequest object and saving the stream to image.
sidd2526_1
0 Points
3 Posts
converting HTML into an image in asp.net application
Feb 04, 2011 06:19 PM|LINK
HI All,
My require ment is such...
1. in asp.net application, i will draw certain shapes (rectangle,elipse etc). using basic html such as table,td tr, <p> etc. ..so basicaly a html deigner in broswer on client side.
2. i will also type some text in <P> tags ...
3. will set fonts , style using using css.
all this will happen in browser just like a basic html editor after that i will post asp.net page back to server. onserver side i want to convert the HTML view that i was seeing in the browser into an image.
a)can some one please suggest how to do this in .net .40 or 3.0 ?
b)are there any third part components that can do this. are these third party components multithreaded and scalable?
here is one ...that seem to do it ..not used it yet..
http://www.acasystems.com/en/web-thumb-activex/faq-convert-html-to-image-in-asp.net.htm
shabirhakim1
Star
13496 Points
2145 Posts
Re: converting HTML into an image in asp.net application
Feb 04, 2011 06:39 PM|LINK
Hi,
You can see code snippet along with explaination here
C#: Generate WebPage Thumbmail Screenshot Image
<div class="info"> 23. July 2008Chris Pietschmann
<div class="act"> Comments (18) <div class="fixed"> </div> </div> <div class="fixed"> </div> </div>There are a few services out there that serve up screenshots of any webpage for you to display on your website. One popular one is Kwiboo; this is the one that DotNetKicks uses. For some time now I've wondered what the easiest way to do this in .NET was, and today I stumbled upon the undocumented WebBrowser.DrawToBitmap method that makes this extremely easy to do.
By the way, I stumbled upon the WebBrowser.DrawToBitmap while taking a look at the source code for the WebPreview tool over at SmallSharpTools.com.
Here's a sample method that returns a Bitmap representation of a webpage:
<div class="content">Here are some example usages of the above method:
</div>asp.net - How to convert *.aspx (HTML) page to Image format ...
Regards
sidd2526_1
0 Points
3 Posts
Re: converting HTML into an image in asp.net application
Feb 04, 2011 08:59 PM|LINK
Thanks however what i m trying to do is some what different...
i do not want to make request to a web page and convert the out put into image....instead i need to do following..
belwo is the exact sequence...may be it was unclear in my earlier post..
1. use will request may asp.net web page in browser.
2. he will use the html editor on this page to create some html layout.
3.he will hit 'save to image' button on this page. clicking on this button will do a post back to the server.
4. now the server side in code behind,upon post back, i want to collect what was the view in browser before user hit 'save to image' button and convert that view into image....
is this possible...it is different than requesting a URL using a webrequest object and saving the stream to image.
Thanks
Siddharth