Rants and raves on (mostly) technology
13 Feb
I got this error trying to use the PDF functions in PHP 5.2 on Windows:
PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key ‘objorient’
The problem seems to be with the bundled PDF extension (php_pdf.dll) that comes with PHP 5.2 – it’s a version 5 of the PDFlib. But upgrading to version 6 solved the problem for me.
So the following describes the steps that I took to fix it…
Download the Windows version of PDFlib 6 for “C, C++, Java, PHP”:
http://www.pdflib.com/binaries/PDFlib/604/PDFlib-6.0.4-Windows.zip
You may want to check this page for an updated version of 6 that is higher than 6.0.4:
http://www.pdflib.com/download/pdflib-family/pdflib-6/
Unzip the file and copy “bind\php5\php-520\libpdf_php.dll” to your PHP extension directory (e.g., C:\Program Files\PHP\ext).
Edit your “php.ini” file by commenting out the default PDF extension and adding the new one:
[PHP_PDF]
;extension=php_pdf.dll
extension=libpdf_php.dll
Restart Apache.
In your phpinfo() page, you should see:
PDF Support: enabled
PDFlib GmbH Binary-Version: 6.0.4
PECL Version: 2.0.5
Revision: $Revision: 1.55.2.20 $
Unfortunately, this new PDFlib is a trial version that adds a watermark to all the generated PDFs. So you’ll need to purchase a license and install your key.
A free PDFlib Lite version is available, but you’ll have to compile it yourself.
To install your PDFlib license, you can do the following:
To set the license in your PHP code at runtime, set the license parameter (with your own registration key):
$p = new PDFlib();
$p->set_parameter( “license”, “X600605-009100-45432E-D1E2B4″ );
If you’re using the dompdf library (0.5.1) with CodeIgniter like me, add your key in the “system\plugins\dompdf\dompdf_config.inc.php” file:
#define(”DOMPDF_PDFLIB_LICENSE”, “your license key here”);
define(”DOMPDF_PDFLIB_LICENSE”, “X600605-009100-45432E-D1E2B4″);
If you want to set it globally, create a “licensekeys.txt” under “C:\Program Files\PDFlib”:
PDFlib license file 1.0
# This is a license file template for PDFlib GmbH products.
# You can accumulate multiple CPU keys here (line by line).
# Replace the 0 in the third column with your actual license key.#PDFlib 6.0.4 0
PDFlib 6.0.4 X600605-009100-45432E-D1E2B4
Set the system environment variable (under Control Panel > System > Advanced > Environment Variables):
PDFLIBLICENSEFILE=C:\Program Files\PDFlib\licensekeys.txt
You can also set it in the Registry. I didn’t try this, but this page has more instructions:
http://www.pdflib.com/pdflib-cookbook/general-programming/license-key/
That should do it. Now create a sample PDF with PHP. See these pages for examples:
http://ca.php.net/manual/en/ref.pdf.php
http://www.digitaljunkies.ca/dompdf/usage.php
I hope that helps.
1 Oct
With the increased security in Windows Vista, installing server applications can be a pain compared to XP/2000/2003. But here’s a quick solution:
msiexec /i apache*.msi
where, apache*.msi is the name of the actual file. Tip: press Tab after “apache” to use the auto-complete feature. Then continue the setup as you normally would.
msiexec /i php*.msi