[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

Save DIV to image file

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
dimmergeek
Asked:
dimmergeek
1 Solution
 
Ray PaseurCommented:
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
 
dimmergeekAuthor Commented:
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
 
AdamSenior DeveloperCommented:
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
 
Ray PaseurCommented:
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
 
jb1devCommented:
You might also consider using PhantomJS to do this.
http://phantomjs.org/

https://github.com/ariya/phantomjs/wiki/Screen-Capture
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