PHP Classes

Binary or PHP Extension ?

Recommend this page to a friend!

      WKHTMLTOPDF HTML to PDF creator  >  All threads  >  Binary or PHP Extension ?  >  (Un) Subscribe thread alerts  
Subject:Binary or PHP Extension ?
Summary:Which is better: the binary or the php extension?
Messages:6
Author:PHP-4-Business
Date:2012-04-11 08:05:06
Update:2012-04-12 12:26:56
 

  1. Binary or PHP Extension ?   Reply   Report abuse  
Picture of PHP-4-Business PHP-4-Business - 2012-04-11 08:05:06
This class allows you to use either the binary executable or the php function.

To use the binary you just need to install the statically compiled program, from the project home page and that's all you need.

To use the php extension you need to install the compiled libwkhtmltopdf and then download and compile Matt Reiferson's wrapper function. This may require you to update your freetype and font-config libraries depending on how old your versions are.

As for execution speed, I found little difference between using the binary and the php extension. The extension is, of course, slightly faster but unless you have 100s of pdfs to generate as a batch then you probably won't notice any real-world difference.

Personally I use the php extension because I'm a purist.

Note: when using the php extension it's important you understand the difference between "global" and "object" settings to the engine - see the libwkhtmltopdf documentation. (For the binary program this isn't important).

  2. Re: Binary or PHP Extension ?   Reply   Report abuse  
Picture of Carlos Cabral Carlos Cabral - 2012-04-11 12:01:27 - In reply to message 1 from PHP-4-Business
Is there a place where I can download the pre-compiled extension?

  3. Re: Binary or PHP Extension ?   Reply   Report abuse  
Picture of PHP-4-Business PHP-4-Business - 2012-04-11 22:53:43 - In reply to message 2 from Carlos Cabral
Not that I know of.

  4. Re: Binary or PHP Extension ?   Reply   Report abuse  
Picture of PHP-4-Business PHP-4-Business - 2012-04-12 07:37:17 - In reply to message 3 from PHP-4-Business
Just to expand on that; providing you have a compiler on your server then compiling the extension is really very easy. Unless you have a very old server OS (like I have) then your existing versions of font-config and freetype should be ok.

So to download and build phpwkhtmltox (the extension)
1) download and extract the wkhtmltopdf source package into /tmp
2) download and extract phpwkhtmltox
3) run:

phpize
./configure --with-phpwkhtmltox=/tmp/wkhtmltopdf-0.11.0_rc1
make
make install

4) edit your php.ini and add the line

extension=phpwkhtmltox.so


That should be all you need.



  5. Re: Binary or PHP Extension ?   Reply   Report abuse  
Picture of PHP-4-Business PHP-4-Business - 2012-04-12 07:40:40 - In reply to message 4 from PHP-4-Business
Oops I forgot a step

2a) Download and copy libwkhtmltox.so from libwkhtmltox-0.11.0_rc1-i386.tar into /usr/local/lib

  6. Re: Binary or PHP Extension ?   Reply   Report abuse  
Picture of Carlos Cabral Carlos Cabral - 2012-04-12 12:26:56 - In reply to message 5 from PHP-4-Business
Thanks for the explanation, I'll try it and post the results here :)

 
For more information send a message to info at phpclasses dot org.