Vous souhaitez utiliser la library wkhtmltopdf / wkhtmltoimage dans une application PHP ? Je vous recommande d’utiliser Snappy.
Si vous avez l’erreur suivante :
Fatal error: Uncaught exception 'RuntimeException' with message 'The file '/Users/sebastien/Documents/git/test/test.jpg' was not created (command: /usr/local/bin/wkhtmltoimage --format 'jpg' 'http://www.google.fr' '/Users/sebastien/Documents/git/test/test.jpg').' in /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php:276 Stack trace: #0 /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(132): Knp\Snappy\AbstractGenerator->checkOutput('/Users/sebastie...', '/usr/local/bin/...') #1 /Users/sebastien/Documents/git/test/index.php(8): Knp\Snappy\AbstractGenerator->generate('http://www.goog...', '/Users/sebastie...') #2 {main} thrown in /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php on line 276
Pour la faire fonctionner sur MAMP, il vous faudra modifier le fichier /Applications/MAMP/Library/bin/envvars :
export PATH=/usr/local/bin/:$PATH #DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH" #export DYLD_LIBRARY_PATH