In the travel strategy, you need to take the introduction page to generate PDF and JPG images, PDF generated by the "Mpdf HTML generated PDF", and HTML generated JPG again jammed. It is intended to be a pure program generation, but in addition to invoking the remote APIs provided by other Web sites to generate JPG, otherwise the Pure program (GD library and built-in functions, or encapsulated classes) did not find the perfect solution.
Install the extended wkhtmltoimage build.
The installation steps are as follows:
1, server-side download installation wkhtmltoimage,32 and 64-bit difference, the mood of the sky installed is CentOS 5.8 32-bit. However, the Wkhtmltoimage 0.11 version was downloaded but the following error occurred.
Pixmap:cannot Create a qpixmap when no GUI being used
Qpixmap:cannot Create a qpixmap when no GUI being used
Qpixmap:cannot Create a qpixmap when no GUI being used
Qpixmap:cannot Create a qpixmap when no GUI being used
Qpixmap:cannot Create a qpixmap when no GUI being used
Qpixmap:cannot Create a qpixmap when no GUI being used final mood Sky install wkhtmltoimage-0.10.0_rc2-static-i386.tar.bz2 Low version can be generated normally.
32-bit
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.10.0_rc2-static-i386.tar.bz2
Tar jxf wkhtmltoimage-0.10.0_rc2-static-i386.tar.bz2
CP Wkhtmltoimage-i386/usr/local/bin/wkhtmltoimage
64-bit
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2
MV wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2 Wkhtmltoimage-0.10.0_rc2-static-amd64.tar
TAR-XVF Wkhtmltoimage-0.10.0_rc2-static-amd64.tar
MV Wkhtmltoimage-amd64/usr/bin/wkhtmltoimage
In this way, the installation is successful, you can test wkhtmltoimage http://www.111cn.net/screenshot.png
2, php execution wkhtmltoimage generate pictures
The code is as follows |
Copy Code |
Set_time_limit (0); Shell_exec ('/usr/local/bin/wkhtmltoimage http://www.111cn.net//usr/local/wwwroot/111cn.net/5eyi.jpg '); |
If you use foreach batch generation, sleep (10) is recommended, pausing for a few seconds after each build.