PHP Html to Pdf Converter

Step 1: Preparation

Login to your CentOS 6.x machine.

Step 2: Install Dependencies

Now that I mentioned it, there are two items needed in order to install the wkhtmltopdf:

  1. xorg-x11-fonts-Type1
  2. xorg-x11-fonts-75dpi

Install the two items with the following command

yum install -y xorg-x11-fonts-75dpi
yum install -y xorg-x11-fonts-Type1

Step 3: Install wkhtmltopdf

Next, download the wkhtmltopdf RPM file.



After the file has been downloaded, run the command:

rpm -Uvh wkhtmltox-


Step 4: Testing

And now for the test. Run the command (and make sure that the computer is accessible to internet):

wkhtmltopdf google.pdf

During the generation, it will show something like this:

Loading pages (1/6)
Counting pages (2/6) 
Resolving links (4/6) 
Loading headers and footers (5/6) 
Printing pages (6/6)

If the command generates the from the website to PDF file successfully, it is obvious that the wkhtmltopdf is working.


 echo exec('/usr/local/bin/wkhtmltopdf file.html file.pdf');

CentOS Clear Memory with Terminal

This will show you usage before Drop caches and after it, just copy / paste to your SSH Terminal window and execute.

Please be aware not to run while MySQL and Apache are running and while you run any process so it don’t stop.

free -m ; echo 1 > /proc/sys/vm/drop_caches ; free -m

Install Imagick on WHM

Go to WHM -> Software -> Module Installers -> PHP Pecl (manage). On the box below “Install a PHP Pecl” enter “imagick” and click “Install Now” button – that’s all. Restart Apache.


If you decide to uninstall it’s as easy as the installation process:
ImageMagick: /scripts/cleanimagemagick
Imagick: WHM -> Software -> Module Installers -> PHP Pecl (manage). Click on Uninstall button for Imagick


If you get the following error;

checking ImageMagick MagickWand API configuration program… configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
ERROR: `/tmp/pear/temp/imagick/configure –with-imagick’ failed

You need to install the ImageMagick devel package.

$ yum update
$ yum install ImageMagick-devel

The following command may be required if you get an error.

$ yum -y install ImageMagick-devel ImageMagick-c++-devel