views:

815

answers:

6

I have an ASP.Net application which as desired feature, users would like to be able to take a "snapshot". While I know this can be simulated, it would be really great to have a way to take a URL (or the current rendered page), and turn it into an image which can be stored on the server.

Is this crazy? Is there a way to do it? If so, any references?

+3  A: 

Browsershots has an XML-RPC interface and available source code (in Python).

Mark Cidade
+7  A: 

I can tell you right now that there is no way to do it from inside the browser, nor should there be. Imagine that your page embeds GMail in an iframe. You could then steal a screenshot of the person's GMail inbox!

This could be made safe by having the browser "black out" all iframes and embeds that would violate cross-domain restrictions.

You could certainly write an extension to do this, but be aware of the security considerations outlined above.

phyzome
Ok, how about a Windows add in for the Browser like Snag-It, which can capture the picture, and save it or post it to a site? Is that possible?
pearcewg
You might look at the Abduction extension for Firefox as inspiration. I don't think you're going to find anything ready-built, though, let alone cross-platform.
phyzome
+1  A: 

You could try a browser plugin like IE7 Pro for Internet Explorer which allows you to save a screenshot of the current site to a file on disk. I'm sure there is a comparable plugin for FireFox out there as well.

tbreffni
+3  A: 

I used the free assembly UrlScreenshot.dll which you can download here.

Works nicely!

There is also WebSiteScreenShot but it's not free.

jdecuyper
+1  A: 

If you want to do something like you described. You need to call an external process that prints the IE output as described here.

Pascal Paradis
+1  A: 

Why don't you take another approach?

If you have the need that users can view the same content over again, then it sounds like that is a business requirement for your application, and so you should be building it into your application.

Structure the URL so that when the same user (assuming you have sessions and the application shows different things to different users) visits the same URL, they always see same thing. They can then bookmark the URL locally, or you can even have an application feature that saves it in a user profile.

Part of this would mean making "clean urls", eg, site.com/view/whatever-information-needed-here.

If you are doing time-based data, where it changes as it gets older, there are probably a couple possible approaches.

  • If your data is not changing on a regular basis, then you could make the "current" page always, eg, site.com/view/2008-10-20 (add hour/minute/second as appropriate).
  • If it is refreshing, and/or updating more regularly, have the "current" page as site.com/view .. but allow specifying the exact time afterwards. In this case, you'd have to have a "link to this page" type function, which would link to the permanent URL with the full date/time. Look to google maps for inspiration here-- if you scroll across a map, you can always click "link to here" and it will provide a link that includes the GPS coordinates, objects on the map, etc. In that case it's not a very friendly url but it does work quite well. :)
gregmac