Requirements
In order to use the ClibPDF functions you need to install
the ClibPDF package. It is available for download from FastIO,
but requires that you purchase a license for commercial use.
PHP requires that you use cpdflib >= 2.
Installation
To get these functions to work, you have to compile PHP
with --with-cpdflib[=DIR]. DIR is the cpdflib install directory,
defaults to /usr. In addition you can specify the jpeg library
and the tiff library for ClibPDF to use. To do so add to
your configure line the options --with-jpeg-dir[=DIR] --with-tiff-dir[=DIR].
Runtime Configuration
This extension has no configuration directives defined in
php.ini.
Predefined Constants
The constants below are defined by this extension, and will
only be available when the extension has either been compiled
into PHP or dynamically loaded at runtime.
CPDF_PM_NONE (integer)
CPDF_PM_OUTLINES (integer)
CPDF_PM_THUMBS (integer)
CPDF_PM_FULLSCREEN (integer)
CPDF_PL_SINGLE (integer)
CPDF_PL_1COLUMN (integer)
CPDF_PL_2LCOLUMN (integer)
CPDF_PL_2RCOLUMN (integer)
Examples
Example 1. Simple ClibPDF Example
<?php
$cpdf = cpdf_open(0);
cpdf_page_init($cpdf, 1, 0, 595, 842, 1.0);
cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
cpdf_begin_text($cpdf);
cpdf_set_font($cpdf, "Times-Roman", 30, "WinAnsiEncoding");
cpdf_set_text_rendering($cpdf, 1);
cpdf_text($cpdf, "Times Roman outlined", 50, 750);
cpdf_end_text($cpdf);
cpdf_moveto($cpdf, 50, 740);
cpdf_lineto($cpdf, 330, 740);
cpdf_stroke($cpdf);
cpdf_finalize($cpdf);
Header("Content-type: application/pdf");
cpdf_output_buffer($cpdf);
cpdf_close($cpdf);
?>
The pdflib distribution contains a more complex example
which creates a series of pages with an analog clock. Here
is that example converted into PHP using the ClibPDF extension: