Solved

Save DIV to image file

Posted on 2013-11-27
5
1,966 Views
Last Modified: 2013-12-19
I have an Intranet app using PHP and jpGraph to generate a line chart on my page using data from a database used for tracking production rate versus production goal.

Above the chart, I have text displaying various color-coded metric values.  Below the chart I haev a running tally showing the number of end-of-line defects for the current run.  All of thjis is placed in a single DIV on my page.  There are other divs with other data, but the are not important.

What I am looking for is a way to capture the contents of the chart div (including all text) AS LAYED OUT ON THE SCREEN and save that to an image file on my network for use by other apps.

I essetially want to perform an automated "snipping tool" like Windows 7 has.

Is this possible at all?

Note: I am not using HTML5, so canvas is out as a solution....
0
Comment
Question by:dimmergeek
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39681969
Why not use HTML5?  It's what everyone is using today!

But that aside, if you use Windows there are some "imagegrab" functions.
http://php.net/manual/en/function.imagegrabwindow.php

Also, you might be able to send the graph to the file system this way:
http://jpgraph.net/doc/faq.php#F2-1
0
 
LVL 7

Author Comment

by:dimmergeek
ID: 39682000
Ray, that looks promising, but it also appears to grab the contents of the entire window.  I just want a particular div.  Alternatively, is there a way I can grab the entire window and crop out the area I do not need?
0
 
LVL 12

Expert Comment

by:Cyber-spy
ID: 39682013
Are you trying to do this automatically with a script or manually?

If you want to automate it, here is a PowerShell script you can use to screenshot the entire screen or just a windows and save it to a file

http://gallery.technet.microsoft.com/scriptcenter/eeff544a-f690-4f6b-a586-11eea6fc5eb8
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39682061
grab the entire window and crop out the area
Yes, there is this:
http://php.net/manual/en/function.imagecrop.php

If you're on a lower level of PHP, you have imageCopy() but there is some calculation you would need to do.  It's a project that kinds of works in reverse.  Normally PHP is used on the server to generate data (HTML, JS, CSS) that is sent to the client.  When you start trying to use PHP to get client data you're really swimming upstream and it's probably better to look for a different approach.
0
 
LVL 14

Expert Comment

by:jb1dev
ID: 39682203
You might also consider using PhantomJS to do this.
http://phantomjs.org/

https://github.com/ariya/phantomjs/wiki/Screen-Capture
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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)

895 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

14 Experts available now in Live!

Get 1:1 Help Now