Install the PHP 5 pdflib extension

    Task


    There is a fairly large chunk of code using pdflib to generate PDF . There is Windows + Denver 3 on the local machine and Ubuntu (+ standard set - apache 2.2, php 5.2.10) on the dev server. Task: Install the PHP pdflib extension on both machines. The problem lies in the fact that:
    1) the free version pdflib - pdflib lite on offsayte exists only in the form of source code;
    2) in the source codes of pdflib lite there is no code of the PHP pdflib extension itself (I did not find out about this right away, at first I had to fill a few cones);
    3) in the case of Ubuntu - there is no standard package with pdflib in the repository (maybe it still exists, but in 2 days of searching I did not find it);
    4) in the case of Windows - even if there were source codes for the extension, there is no desire to install Visual Studio 6.0 just to compile the extension.

    Solution for Windows + Denver 3


    The solution turned out to be very simple.
    1. We go to http://php.net/releases/ and download a collection of PECL modules for the version of the PHP interpreter that is installed in your Denver 3. In the case of the latest version of Denver 3 from offsite, this is php 5.2.4, so download the next zip archive: http://museum.php.net/php5/pecl-5.2.4-Win32.zip .

    2. From this archive we get the cherished php_pdf.dll and put it in 3. B

    \usr\local\php5\ext\

    \ usr \ local \ php5 \ php.ini we find the Windows Extensions section and add line 4 to it . Restarting Denver - this completes the installation of the extension. In the case of Ubuntu, everything turned out to be a bit more complicated.

    extension=php_pdf.dll





    Solution for Ubuntu


    1. Download the pdflib lite source code from offsite:
    wget http: // www.pdflib.com /binaries/PDFlib/704/PDFlib-Lite-7.0.4p4.tar.gz

    2. Unpack into a temporary directory and go to it:
    -zxvf the PDFlib-tar will Lite-7.0.4p4.tar.gz - the C / tmp
    cd /tmp/PDFlib-Lite-7.0.4p4

    3. Compile and install pdflib lite:
    ./configure
    make
    make install

    4. Compile and install the PHP pdf.so extension using the pecl utility :
    pecl install pdflib

    When pecl asks for the name of the directory where pdflib lite is installed - indicate if it turned out that in your case pdflib lite was installed in another directory - specify it. 5. Connect the expansion pdf.so . After working pecl, it may turn out that the pecl extension has placed the pdf.so extension in your php extension folder but not connected it. In this case, either right at the end of php.ini, add the line or create a separate .ini file in the directory where the .ini files of other extensions are located and write this line to it and not to php.ini. 6. Restart the Apache.

    /usr/local






    extension=pdf.so




    /etc/init.d/apache2 restart

    Notes


    1. If you do not have pecl installed , you need to install it using the following command:
    apt-get install dh-make-php php5-dev

    2. If suddenly when you try to install a package using apt-get install you see an error - the file was not found on the server, then apparently you have not updated the ubuntu for a long time. You need to update the list of packages using the command
    apt-get update

    3. If you use windows font files that have cp1251 encoding and you do not have cp1251 locale in ubunt, you must install it using the command
    localedef -c -i ru_RU -f CP1251 ru_RU.CP1251

    4. Due to the fact that the free version of pdflib lite is quite limited in functionality, it is better not to use it in new projects. To generate pdf in new projects, it is better to look towards dompdf or FPDF .

    Also popular now: