dsHtml2ImagePlugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Plugin Information Installation Contribute
dsHtml2ImagePlugin
Plugin image
1
user
Sign-in
to change
your status

dsHtml2ImagePlugin

A Symfony 1.x plugin that utilizes the wkhtmltoimage unix utility to create snapshot images of web pages

Dependencies

  • sfImageTransformPlugin
  • wkhtmltoimage
  • xvfb-run

wkhtmltoimage

The plugin comes complete with both the 32 and 64 bit binaries of wkhtmltoimage-0.11.0_rc1 which are located in the plugins lib/vendor/wkhtmltoimage folder

Further instructions can be found here; http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltoimage_0.10.0_rc2-doc.html

Xvfb

wkhtmltoimage requires an X11 server in order to render the HTML to be captured. I've chosen to use xvfb to do this. To install on ubuntu, simply run the following;

$ sudo apt-get install xvfb

Useage

$save_path = /absolute/path/to/image.jpg';
$url = 'http://www.url.to.capture.com/';

$h2i = new dsHtml2Image($url,$save_path);
$h2i->setOptions(array(
    'quality' => 80,
    'disable-javascript' => ''   
));
$img = $h2i->getImage();

Will capture a full size screen capture of the url supplied, with the quality set at 80% and the javascript disabled and save to the path you specified.

The method getImage will return an instance of sfImage preloaded with the screen capture for you to manipulate as required.