• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Creating a screenshot of a HTML page at runtime in a Web Browser (not just IE)

Hi,

I am looking for a solution where a user of a webpage can click on a button in a HTML page and can save the snapshot of the HTML page (or for that instance the screenshot of the browser) in his desktop.

Certain points to note:

1) The HTML pages are not local and are located in a server
2) The user cant be asked to install any ActiveX controls on his/her machine
3) The solution should work across browsers (not just IE)
4) The server doesnt support ColdFusion
5) The image should be a JPEG file.

I know of  couple of solutionS which are ActiveX based and can work on the server side but most of them are just compatible with IE.

This is a bit urgent and hence I am assigning maximum points to this question.

Thanks,
KP

 
0
krishnaprathab
Asked:
krishnaprathab
  • 10
  • 9
  • 5
  • +3
2 Solutions
 
Eternal_StudentCommented:
You would need to build a whole application to do this. It is not a simple thing you could just script. I think there is a site called http://www.browsercam.com/ that basically does this but you need to be a member, which costs money.

Good luck anyway.
0
 
basicinstinctCommented:
0
 
JohnModigCommented:
Hi KP.
Does your server support .NET? If so, I recommend you to use this code:

ScreenCapture
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1916&lngWId=10

Regards,
John
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ClickCentricCommented:
This actually, theoretically, could be possible with a server-side solution if all you want is a snapshot of the page.  You'd have to pass to the server some form of definitive url that can provide the server with access to the exact same page as what they're seeing.  The html for the page would have to be generated and passed through a rendering system to create the image and then it could be sent back as a jpeg file.  Of course, this would require a great deal of server power, probably several computers with every browser you'd want to support loaded on it to pass through as the rendering system.  So, long answer is yes, short answer is no, but.
0
 
ClickCentricCommented:
Client-side, without the client downloading or accepting or installing something, there's absolutely no way.  If there were, they'd plug it because it would be a huge security risk.
0
 
krishnaprathabAuthor Commented:
Even if server side image generation was possible - in the kind of scenario I am facing the screenshot has to be saved with USER ENTERED valeus in the page - this would mean a lot of modification to the existing pages to accomodate this change.

A ideal approach for me would be able to send the data from the client side to the server side instead of doing it on the server side.

One of my developer has come up with a solution using some Java applet I will test it on Monday and let you know if that worked. I am also going to try out JohnModig's solution.

Thanks,
KP
0
 
ClickCentricCommented:
There is no cross-browser capable method of generating a screenshot client side.  Not without the person installing something.  
0
 
krishnaprathabAuthor Commented:
Hi ClickCentric,

Can you let me know if there is a ActiveX based solution to this problem. I am not specific about cross-browser and corss-os compatibility as the content will be delievered only on Windows and only on IE.

Thanks,
KP
0
 
Eddie ShipmanAll-around developerCommented:
If It was IE Only, I would suggest a BHO (Browser Helper Object) but it would also require installation.
You can program the BHO to do this.
0
 
krishnaprathabAuthor Commented:
Hi Eddie,

Can you tell me what a BHO is and how can one program this?

Thanks,
KP
0
 
Eddie ShipmanAll-around developerCommented:
I'm researching something for you, please be patient.
0
 
ClickCentricCommented:
Be aware that most BHO's, especially one that's not easily identifiable, are viewed as malware by detectors and there's a good chance of them needing to reinstall it regularly as using IE means getting malware which means running malware scans which means erasing things that the malware scanner thinks might be a threat.  And anything that captures the browser screen is arguably spyware, so you may want to let people know in advance if you go this route that if they run a malware scan, theymay have to reinstall the BHO.
0
 
JohnModigCommented:
Better to do it server-side imho. I have done this successfully several times using code from the link I provided you with earlier. Have you tried it yet?

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1916&lngWId=10
0
 
Eddie ShipmanAll-around developerCommented:
You can not do it server side without an executable ON the server and most hosts won't allow that.
0
 
JohnModigCommented:
Not true. If you read the link I posted, you will see that this is a .NET class. In other words, it's just simple text (vb code) and not in any way an executable. All you need from the server is to have the .NET framework installed. The code doesn't use sendkeys or the clipboard, but is a proper implementation with the .NET API. Benefits from doing it server side is that the output will be the same regardless of your users choice of web browser and security settings.
0
 
Eddie ShipmanAll-around developerCommented:
It still won't do server-side because the USER is not surfing on the server. In otherwords, what the
user sees, the server isn't seeing, unless you magically can see through the wire...;-)
0
 
Eddie ShipmanAll-around developerCommented:
krishnaprathab, is this a Windows web server?
0
 
ClickCentricCommented:
I think the idea was to take a snapshot of what the user was seeing, not just the page.  There are plenty of ways to view a rendered page server-side.  But, there's really no secure way of doing this without the user installing a program because of the security implications.  Even a user running IE would have to have pretty loose security settings to allow this so easily.  
0
 
Eddie ShipmanAll-around developerCommented:
Not so fast my friend, I am working on something that'll "amaze" you...
0
 
ClickCentricCommented:
If you mean me, it won't amaze me in the least.  My issue was never that it couldn't be done.  My issue was with for how few people it would actually work.  And how likely it was that a malware/spyware scanning program would be to inhibit and/or remove it or at least suggest it's removal.  If a solution that works for some of the people, some of the time, if they do everything they need to do to make it work is acceptable, then yes, it can be done.   But, at that point, why not just use any of dozens of screen capture programs already available?
0
 
krishnaprathabAuthor Commented:
Thanks for all those who are trying this solution. As I has mentioned earlier and as EddieShipman rightly said what the USER sees has to be saved and not what the server sees.

>> is this a Windows web server? - Yes

Server side solutions really doesnt help here because the user entered values has to be send back to the server to create a snapshot.

Thanks,
KP
0
 
Eddie ShipmanAll-around developerCommented:
krishnaprathab,
A server-side solution would work in this manner:
You pass the url you want to capture to a script, the script forks (runs) an executable,
on the server, to generate the image and then the script returns the image to the client.

However, I know of a webservice that does that for you and am working on a solution to call that
webservicce to capture the screenshot for you.

hold on a little while longer, please.
0
 
Eddie ShipmanAll-around developerCommented:
ok, now have it working...
Place a link on your page like this:

<a href="shot.php?URL=www.mywebpage.com"> Click for Snapshot of this Page</a>

shot.php source code:
<html>
<body>
<?
  $url = $_GET["URL"];
  echo "<img src='http://webdesignbook.net/snapper.php?url=$url&full' alt='' />";
?>  
</body>
</html>

This will return a page with the image snapshot of the passed URL.
In order to have this "included" in every page, you will have to write a BHO (Browser Helper Object)
to inject the link into all navigated pages.

0
 
ClickCentricCommented:
Wasn't the goal to capture a screenshot of the live browser window?  If so, a server-side solution will never work.  Is this for some form of debugging so people can capture their screen so that you can see exactly what it looks like?  I hate to see EddieShipman spend all of this time on this if that's the case because the road he's going down will never lead to this solution if I'm right.

If all that's needed is a jpg that shows the form with the values entered and the form values can be submitted to the server, then just about any server-side language could do this relatively easily...though I don't see what the advantage to turning it into a jpg would be in that situation, which is why I don't think that's the issue.
0
 
Eddie ShipmanAll-around developerCommented:
I gave a sample of how a server-side solution would work, did you not see it above my last post?
0
 
Eddie ShipmanAll-around developerCommented:
The server-side execuatable would "open" the passed URl and gen the screenshot to a
particular directory then the script would return it to the client.

I've seen lots of examples of this using HQScreen.exe and PHP, Google is my friend!!!
0
 
krishnaprathabAuthor Commented:
I dont know how to thank you guys for the amount of time you are spending on this. I am going to go ahead and split the points between two. I still have to put in the solution on a server and test this out and I dont want you guys to spend your precious time on this forever.

Thanks for all who took out the time to answer this question. Your effort is much appreciated.

Thanks,
KP
0
 
ClickCentricCommented:
But a server-side only method still wouldn't work if you want to capture the live state of a page in a browser window.  It will only capture the state transmitted to the server.  This is pretty much written in stone.   The only way a server-side method could do this is if the server connects to the client, gains access to the relative window and takes a snapshot of it.  Now, while it wouldn't surprise me if at one point Windows was in a state where such a horrible security flaw were available to exploit, those days have likely come and gone...and if it is possible at this point, it's at least far more complicated.  If the goal is the live state of a page in the browser, only a client-side app could accomplish this.  Now, this could be done with a java applet...though transmitting it to the server would likely require clicking on Ok to give permission for it to run at least once.  It would, however, greatly slow down the page load (at least each time it has to be loaded...should remain cached for a while.  Would probably at least last through a session.)  However, this would work for capturing the screen...I'm not sure it would be possible to actually narrow it down to the browser window alone.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 9
  • 5
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now