Solved

JavaScript Print Screen

Posted on 2013-11-14
10
386 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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 500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

839 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