CXIV. PDF 函数
简介
The PDF functions in PHP can create PDF files using the PDFlib library which was initially created by Thomas Merz and is now maintained by PDFlib GmbH. The documentation in this section is only meant to be an overview of the available functions in the PDFlib library and should not be considered an exhaustive reference. For the full and detailed explanation of each function, consult the PDFlib Reference Manual which is included in all PDFlib packages distributed by PDFlib GmbH. It provides a very good overview of what PDFlib is capable of doing and contains the most up-to-date documentation of all functions. For a jump start we urge you to take a look at the programming samples which are contained in all PDFlib distribution packages. These samples demonstrate basic text, vector, and graphics output as well as higher-level functions, such as the PDF import facility (PDI). All of the functions in PDFlib and the PHP module have identical function names and parameters. Unless configured otherwise, all lengths and coordinates are measured in PostScript points. There are generally 72 PostScript points to an inch, but this depends on the output resolution. Please see the PDFlib Reference Manual included in the PDFlib distribution for a more thorough explanation of the coordinate system used. With version 6, PDFlib offers an object-oriented API for PHP 5 in addition to the function-oriented API for PHP 4. The main difference is the following: In PHP 4, first a PDF resource has to be retrieved with a function call like $p = PDF_new(). This PDF resource is used as the first parameter in all further function calls, such as in PDF_begin_document($p, "", ""). In PHP 5 however, a PDFlib object is created with $p = new PDFlib(). This object offers all PDFlib API functions as methods, e.g. as with $p->begin_document("", ""). In addition, exceptions have been introduced in PHP 5 which are supported by PDFlib 6 and later as well. Please see the examples below for more information. 注: If you're interested in alternative free PDF generators that do not utilize external PDF libraries, see this related FAQ. 需求
PDFlib Lite is available as open source. However, the PDFlib Lite license allows free use only under certain conditions. PDFlib Lite supports a subset of PDFlib's functionality; please see the PDFlib web site for details. The full version of PDFlib is available for download at http://www.pdflib.com/products/pdflib/index.html, but requires that you purchase a license for commercial use. Issues with older versions of PDFlib
Any version of PHP 4 after March 9, 2000 does not support versions of PDFlib older than 3.0. PDFlib 4.0 or greater is supported by PHP 4.3 and later. 安装
本 PECL 扩展未绑定于 PHP 中。 进一步信息例如新版本,下载,源程序,维护者信息以及更新日志可以在此找到: http://pecl.php.net/package/pdflib. To get these functions to work in PHP < 4.3.9, you have to compile PHP with --with-pdflib[=DIR]. DIR is the PDFlib base install directory, defaults to /usr/local. As of PHP 4.3.9, you must install this extension through PEAR, using the following command: pear install pdflib.