Solved

Save DIV to image file

Posted on 2013-11-27
5
1,979 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 109

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 109

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

806 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