//jerrywalsh.org

coding, hacking, startups, computer security, technology and more

HOWTO: Compile PDFlib for PHP on Linux

Here's a small script which you can use to compile PDFlib support for PHP on Linux. This should work on any Debian based Linux distribution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# Download the PDFLib Lite Linux source from here first:
# http://www.pdflib.com/download/pdflib-family/pdflib-lite-7/
# put the download in the same location as this script
# NOTE: you will be prompted by the pecl installation at the end
# of the process for a path - you'll need to enter /usr/local/ here
#
# Author: jbw
# DateCreated: Mon, 22 Mar 2010

# We need root privileges ..
if [ "$USER" != "root" ]; then
  chmod +x "$0"
  gksudo "$0"
  exit
fi

dpkg -l | grep -q build-essential || \
  apt-get install build-essential

tar zxvf PDFlib-Lite-7*.tar.gz && \
  cd PDFlib-Lite-7*/ && \
  ./configure && \
  make && \
  make install

dpkg -l | grep -q php-pear || \
  apt-get install php-pear

dpkg -l | grep -q php5-dev || \
  apt-get install php5-dev

pecl install pdflib

If you don't plan on using the dl() method to load this module dynamically then you may need to modify the php configuration so it autoloads the pdf.so extension.