Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JavaScript Print Screen

Posted on 2013-11-14
10
Medium Priority
?
410 Views
Last Modified: 2013-12-06
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
Comment
Question by:guswebb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 39648169
just use:

window.print()
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39648177
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39648278
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Author Comment

by:guswebb
ID: 39648316
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
 
LVL 33

Accepted Solution

by:
Big Monty earned 2000 total points
ID: 39648372
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
 
LVL 9

Author Comment

by:guswebb
ID: 39648846
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
 
LVL 43

Expert Comment

by:Rob
ID: 39701082
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39701083
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
 
LVL 9

Author Comment

by:guswebb
ID: 39701470
The HTML2 canvas material was very useful, thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question