Ubuntu 10.04 & PHP 5.3: Setup PDFlib 6 with PECL

If you want to use the (old) PDFlib 6 (because you have paid for a license), you will get the following error when you try to install the latest pecl pdflib package (version 2.1.8) for PHP 5.3:

running: make
/bin/bash /var/tmp/pear-build-root/pdflib-2.1.8/libtool --mode=compile cc  -I. -I/tmp/pear/temp/pdflib -DPHP_ATOM_INC -I/var/tmp/pear-build-root/pdflib-2.1.8/include -I/var/tmp/pear-build-root/pdflib-2.1.8/main -I/tmp/pear/temp/pdflib -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/root/PDFlib-6.0.4-Linux/bind/c/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/pdflib/pdf.c -o pdf.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/pdflib -DPHP_ATOM_INC -I/var/tmp/pear-build-root/pdflib-2.1.8/include -I/var/tmp/pear-build-root/pdflib-2.1.8/main -I/tmp/pear/temp/pdflib -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/root/PDFlib-6.0.4-Linux/bind/c/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/pdflib/pdf.c  -fPIC -DPIC -o .libs/pdf.o
/tmp/pear/temp/pdflib/pdf.c:135:21: error: php_pdf.h: No such file or directory
make: *** [pdf.lo] Fehler 1
ERROR: `make' failed

PDFlib 6 is is officially no longer supported, but using the previous version 2.1.7 of the pecl package (even if the changelog of 2.1.8 explicitly note the PHP 5.3 compatibility) does the trick. In detail the installation instructions are:

# sudo apt-get install php5-dev 
# sudo apt-get install build-essential
# wget http://www.pdflib.com/binaries/PDFlib/604/PDFlib-6.0.4-Linux.tar.gz
# tar -xzf PDFlib-6.0.4-Linux.tar.gz
# sudo pecl install pdflib-2.1.7 # path to pdflib installation? -> /[PATH_TO_EXTRACTED_PDFLIB]/PDFlib-6.0.4-Linux/bind/c

To activate the PDFlib extension create the file /etc/php5/apache2/conf.d/pdflib.ini with the following content:

;configuration for php pdflib module

After restarting your web server the PDFlib extension will be active.