0

I have a php file that can generate html or js files that would draw a graph in the browser.

But since this files have to be created by php on server side, I cannot have browser involved. What I want to do, is to be able to emulate the browser and create an image from those files directly from php, in order to email them to the appropriate department.

I think this can be done in the following steps:

  1. Some executable program that can be run from Command Promt with an argument being my file
  2. PHP could send commands to Command Promt telling it to run "the created file" with that program which would generate the image.
  3. Then I would email that image

Example of usability

Lets say you are running extjs web application in your browser, right? There is no user interaction, it might stay running for days. Now without doing anything you want to send an image of your CPU performance graph to your testing department.

Does anyone know the best way of doing this? Thanks

13
  • You mean like, generate a print-screen of your page or something? Commented Apr 20, 2014 at 21:16
  • the image looks exactly like it would have been in the browser. If html or JS creates i.e. ExtJS charts, I want to generate the picture of that chart in php without browser involvment Commented Apr 20, 2014 at 21:17
  • If you just need to render an image (let say a JPEG) or even a PDF it's easier to just use a graphic rendering library. Commented Apr 20, 2014 at 21:19
  • I'm still unsure about what you mean. If you have JS generating this image with Canvas, I suppose you can rewrite your script with GD2 to create it in PHP. Commented Apr 20, 2014 at 21:19
  • @Havenard: Lets say you are running extjs web application in your browser, right? There is no user interaction, it might stay running for days. Now without doing anything you want to send an image of your CPU performance graph to your testing department. Commented Apr 20, 2014 at 21:24

2 Answers 2

2

Use server - side graph image generator. You don't need to emulate the browser and then fetch back to server - it's way more complicated and unreliable.

I have used JPGraph (http://jpgraph.net) in few projects - it can generate graph images on server side into some temporary directory, and then you can either include into email or output to client. If you find jpGraph not suitable solution, take a look at alternatives:

But if you still find that fetching javascript output from client and bringing it back to server is your way to go, then you might want to take a look at http://wkhtmltopdf.org/.

Sign up to request clarification or add additional context in comments.

3 Comments

this is not free, right? Also I do not want to use their graphs, I want to use ExtJS charts. That is why I want to transform html document into image
JPGraph is free, and also some alternatives (see the link). WkhtmlToPdf is also free.
+1 for the answer, but i cannot accept it since this is not what i wanted :)
0

I found what I was looking for, even though it is a little late but still...

I am using phantomjs. It is really cool. You can write php file and give it to phantomjs, it will create image or pdf as if you screen capture from browser.

This is what the command looks like from phantomjs directory:

phantomjs "youJavascriptFile" "outputType" "fileName" "file"

Where

  • outputType can be 'letter' or 'width x height'
  • file can be a http path to your server's php file
  • youJavascriptFile is the js file where you use this other inputs and a little phantomjs magic to create an output.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.