Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I programmatically save part of a web page as an image?

If possible, I would like to do this with a simple button. The users are not terribly comfortable with computers, which is why I haven't just told them to print screen or use the snipping tool.

I know it can be done in Mozilla-based browsers with <canvas> and drawWindow(). But this application is running on Internet Explorer 7 and 8.

The page shows some graphs (generated by a ReportViewer control) based on the input of a couple of dropdowns. Does that mean a client-side script is the only option? Or could I do it in the ASP.NET back end somehow? Perhaps re-generating an image any time the dropdowns are changed?
(I've been a desktop dev for so long that I don't quite "get" what you can and can't do in web apps yet.)

like image 858
Michael Myers Avatar asked May 03 '11 15:05

Michael Myers


1 Answers

From what I understand you've got some drop downs and you're generating a graph based on the input of those drop downs by the user?

So if I was doing this with PHP (just trying to give you ideas here, dunno whats possible and what's not in ASP) I would create an image magic or gdb library script that builds a jpeg based on the variables input in a querystring.

For instance this would output a jpeg image of a simple graph with 3 points on it:

http://mydomain.org/image.php?value1=10&value2=20&value3=30

Then for the front end of my script I would probably use jquery/ajax to call that script and show the image as the user is changing the values.

Then you have an image that you can potentially force download or instruct users to right click and choose "save as".

Anyway, this is just an idea, not a solution. I don't know about ASP.NET, but this is how I would do it in PHP.

like image 193
Thomas Clayson Avatar answered Sep 30 '22 02:09

Thomas Clayson