Task
There is a fairly large piece of code that uses
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 virgins server. Task: install the PHP pdflib extension on both machines. The problem is that:
1) the free version of pdflib - pdflib lite on
offsite exists only in the form of source codes;
2) there is no code for the PHP pdflib extension itself in the pdflib lite source codes (I did not immediately recognize this, I first had to stuff a few cones);
3) in the case of Ubuntu, there is no standard package with pdflib in the repository (maybe it does exist, but after 2 days of searching I never found it);
4) in the case of Windows - even if there were the source codes of the extension, to install Visual Studio 6.0 only in order to compile the extension there is no desire.
Solution for Windows + Denver 3
The solution was very simple.
1. Go to
http://php.net/releases/ and download
the PECL modules collection for the version of the PHP interpreter that you have installed in Denver 3. In the case of the latest version of Denver 3 offsite, this is php 5.2.4, so download the following zip archive:
http://museum.php.net/php5/pecl-5.2.4-Win32.zip .
2. From this archive we get the treasured
php_pdf.dll and put it in
<denwer_root>\usr\local\php5\ext\
3. In <denwer_root> \ usr \ local \ php5 \ php.ini we find the Windows Extensions section and add a line to it
')
extension=php_pdf.dll
4. Restart Denver - on this installation of the extension is complete.
In the case of Ubuntu, everything turned out to be somewhat more complicated.
Ubuntu Solution
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 to a temporary directory and go to it:
tar -zxvf PDFlib-Lite-7.0.4p4.tar.gz - 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 extension
pdf.so using the
pecl utility:
pecl install pdflib
When pecl asks the name of the directory where pdflib lite is installed - we specify
/usr/local
If it turned out that in your case pdflib lite was installed in another directory, we indicate it.
5. We connect the
pdf.so extension.
After running
pecl, it may be that the pecl extension placed the
pdf.so extension in your php extensions folder but did not connect it. In this case, or right at the end of
php.ini append the line
extension=pdf.so
or create a separate .ini file in the directory where the .ini files of other extensions are located and write this line into it, not in php.ini.
6. Restart the Apache.
/etc/init.d/apache2 restart
Notes
1. If you do not have the
pecl utility
installed , then you need to install it using the following command:
apt-get install dh-make-php php5-dev
2. If you see an error when trying to install a package using
apt-get install , the file was not found on the server, then apparently you haven’t updated ubuntu for a long time. You need to update the package list with the command
apt-get update
3. If you use windows files of fonts that are
encoded with cp1251 and you do not have the cp1251 locale in ubunt, you need to 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 .