How to install wkhtmltopdf on CentOS?

First, we need to know which version of wkhtmltopdf binary - 32bit or 64 bit- we need. To do so run this command in CLI:

getconf LONG_BIT

Now depending on the version of your CentOS dowload the first or the second link respectively for 32 and 64 bits:

cd /usr/src

Install necessary packages:

yum install xz urw-fonts libXext openssl-devel libXrender
tar xjf wkhtmltopdf*
cp wkhtmltopdf* /usr/bin/wkhtmltopdf

and test wkhtmltopdf:

wkhtmltopdf test.pdf


After the install I run

After the install I run following code to test it:
wkhtmltopdf test.pdf

But I am getting following error :
root@host [/]# wkhtmltopdf test.pdf
Loading pages (1/6)
Counting pages (2/6)

Resolving links (4/6)

Loading headers and footers (5/6)

Printing pages (6/6)
terminate called after throwing an instance of 'std::bad_alloc'Page 1 of 1
what(): std::bad_alloc

What is going wrong here ? What am I missing ?

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
To prevent automated spam submissions leave this field empty.