The PDF functions in PHP can create PDF files using the PDFlib
library created by Thomas
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. Please consult the
documentation included in the source distribution of PDFlib for
the full and detailed explanation of each function here. It
provides a very good overview of what PDFlib is capable of doing
and contains the most up-to-date documentation of all functions.
All of the functions in PDFlib and the PHP module have identical
function names and parameters. You will need to understand some
of the basic concepts of PDF and PostScript to efficiently use
this extension. 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 documentation included with the source distribution of
PDFlib for a more thorough explanation of the coordinate system
Please note that most of the PDF functions require a
pdfdoc as its first parameter. Please
see the examples below for more
If you're interested in alternative free PDF generators that do not
utilize external PDF libraries, see
this related FAQ.
This extension has been moved to PECL as
of PHP 4.3.9.
Это расширение PECL
не поставляется вместе с PHP.
Дополнительная информация, такая как новый версии,
скачивание, исходные файлы, информация о разработчике и CHANGELOG, могут
быть найдены здесь:
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.
In addition you can specify the jpeg, tiff, and pnglibrary for PDFlib to
use, which is optional for PDFlib 4.x.
To do so add to your configure line the options
When using version 3.x of PDFlib, you should configure PDFlib
with the option --enable-shared-pdflib.
As of PHP 4.3.9, you must install this extension through PEAR, using the following command:
pear install pdflib.
Starting with PHP 4.0.5, the PHP extension for PDFlib is
officially supported by PDFlib GmbH. This means that all the
functions described in the PDFlib manual (V3.00 or greater) are
supported by PHP 4 with exactly the same meaning and the same
parameters. Only the return values may differ from the PDFlib
manual, because the PHP convention of returning
FALSE was adopted. For compatibility reasons,
this binding for PDFlib still supports the old functions, but they
should be replaced by their new versions. PDFlib GmbH will not
support any problems arising from the use of these deprecated
Таблица 1. Deprecated functions and their replacements
Most of the functions are fairly easy to use. The most difficult part
is probably creating your first PDF document. The following
example should help to get you started.
It creates test.pdf
with one page. The page contains the text "Times Roman outlined" in an
outlined, 30pt font. The text is also underlined.
The PDFlib distribution contains a more complex example which
creates a page with an analog clock. Here we use the in-memory
creation feature of PDFlib to alleviate the need to use temporary
files. The example was converted to PHP from the PDFlib example.
(The same example is available in the CLibPDF documentation.)
Пример 3. pdfclock example from PDFlib distribution
An alternative PHP module for PDF document creation based on
FastIO's ClibPDF is
available. Please see the ClibPDF
section for details. Note that ClibPDF has a slightly different API