Solved

JavaScript Print Screen

Posted on 2013-11-14
10
381 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 32

Expert Comment

by:Big Monty
ID: 39648169
just use:

window.print()
0
 
LVL 32

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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 32

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 42

Expert Comment

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

Not enough information to confirm an answer.
0
 
LVL 32

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now