Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

JavaScript Print Screen

I have a web page in ASP.NET which uses a 3rd party graphing tool to display some data. My client would like the ability to simply click a button on the page in order to Print Screen and capture the contents of the active window (or a portion of the web page that we might define e.g. the graph). I assume there will be a way of doing this with JavaScript but we would need to avoid any security warnings if possible.
0
guswebb
Asked:
guswebb
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
just use:

window.print()
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
to put it in a link:

<A HREF="javascript:window.print()">Click to Print This Page</A>

or a button:

<INPUT TYPE="button" onClick="window.print()">
0
 
COBOLdinosaurCommented:
And if you only want to print specific parts of the page you can use a print stylesheet to hide the parts you don't want printed.

Cd&
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
guswebbAuthor Commented:
I may not have been sufficiently clear. I want to screen grab i.e. create an image of what is on screen in the currently active window, and have this held in the clipboard so that the image can be pasted in to PowerPoint for example, not simply launch the printer properties window to send this to a physical printer.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
nothing in your original post is there a mention of a screen shot, only Print Screen...

to do what you're asking now, you may want to look into html2canvas:

http://html2canvas.hertzen.com/
0
 
guswebbAuthor Commented:
I assumed you would be familiar with what Print Screen is (not the same as print screen) not least when in the context of 'capturing the screen contents' or 'a portion of the page e.g. a graph' - my bad, apologies!

That looks like some interesting code which might very well do what I'm looking for. I shall have a play around with this and let you know if it works for my requirement.
0
 
RobOwner (Aidellio)Commented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
The link I sent does exactly what the OP asked, and I can confirm it works, as I've used it before.

I don't really care about the points, but rather it be PAQ'ed so that someone else may find it useful.
0
 
guswebbAuthor Commented:
The HTML2 canvas material was very useful, thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now