Installing PDFlib in MAMP OS X


In this example, I'm going to outline the instructions for installing PDFlib 8 on a MAMP system running PHP 5.2.17. You'll have to make the logical adjustments to the folder names if you've a different setup.

First of all stop the MAMP servers then do the following:

(1) download the correct version of PDFLib for your system and programming language: http://www.pdflib.com/en/download/pdflib-family/pdflib-8/
(2) double-click the downloaded .dmg file to unpack
(3) create a folder called pdflib inside your MAMP htdocs folder
(4) drag the entire contents of the opened .dmg file here
(5) navigate in Finder to Applications/MAMP/htdocs/pdflib/bind/php/php-520
(6) keep the Finder window in point (5) open
(7) open the php.ini file contained in Applications/MAMP/bin/php/php5.2.17/conf
(8) find the line that begins extension_dir and reads something like this:

    ; Directory in which the loadable extensions (modules) reside.
    extension_dir = "/Applications/MAMP/bin/php/php5.2.17/lib/php/extensions/no-debug-non-zts-20060613/"

(9) open the folder that extension_dir points at (/Applications/MAMP/bin/php/php5.2.17/lib/php/extensions/no-debug-non-zts-20060613/)
(10) drag the file libpdf_php.so from the folder you opened in point (5) and drop it into the folder from point (9)
(11) return to the ini.php file you opened in point (7) and add the line "extension=libpdf_php.so" to the section of the file headed:

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;

(12) navigate to MAMP/Library/bin and open the envars file inside a text editor
(13) comment out the DYLD_LIBRARY_PATH content so that it looks like this:

    #if test "x$DYLD_LIBRARY_PATH" != "x" ; then
    #  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
    #else
    #  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
    #fi
    #export DYLD_LIBRARY_PATH
    #

(14) start the MAMP server and go to http://localhost:8888/pdflib/bind/php/hello.php

You should see your first PDF load.

Notes

(i) there are instructions for installing PDFlib in the folder  Applications/MAMP/htdocs/pdflib/doc/common/PDFlib-in-PHP-HowTo.pdf
(ii) if you are using PHP 5.3.- in point (5) you'll navigate to php-530, for PHP 5.4- you'll use php-540, and if you are using PHP 5.5- you'll need to used PDFlib 9 because PDFlib 8 doesn't support it  
(iii) if you are using PDFlib version 9 in point (11) you'll replace  "extension=libpdf_php.so" with "extension=php_libpdf.so"
Endorse  on Coderwall

Comments

  1. i have followed these instructions and i get a blank page when i load the following http://localhost:8888/pdflib/bind/php/hello.php
    any ideas why?

    ReplyDelete
    Replies
    1. no ned to worry, i jut had to restart the server
      thanks for help, great article.

      Delete
  2. i get this fatal error when i run hello.php
    Fatal error: Class 'PDFlib' not found in /Applications/MAMP/htdocs/pdflib/bind/php/hello.php on line 8

    ReplyDelete

Post a Comment