17.05.2014 Views

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.8 PHP Binding<br />

Installing the <strong>TET</strong> Edition for PHP. <strong>TET</strong> is implemented as a C library which can dynamically<br />

be attached to PHP. <strong>TET</strong> supports several versions of PHP. Depending on the version<br />

of PHP you use you must choose the appropriate <strong>TET</strong> library from the unpacked<br />

<strong>TET</strong> archive.<br />

Detailed information about the various flavors and options for using <strong>TET</strong> with PHP,<br />

including the question of whether or not to use a loadable <strong>TET</strong> module for PHP, can be<br />

found in the <strong>PDFlib</strong>-in-PHP-HowTo document which is available on the <strong>PDFlib</strong> web site.<br />

Although it is mainly targeted at using <strong>PDFlib</strong> with PHP the discussion applies equally<br />

to using <strong>TET</strong> with PHP.<br />

You must configure PHP so that it knows about the external <strong>TET</strong> library. You have<br />

two choices:<br />

> Add one of the following lines in php.ini:<br />

extension=libtet_php.dll<br />

extension=libtet_php.so<br />

extension=libtet_php.sl<br />

extension=libtet_php.dylib<br />

; for Windows<br />

; for Unix<br />

; for HP-UX<br />

; for Mac OS X<br />

PHP will search the library in the directory specified in the extension_dir variable in<br />

php.ini on Unix, and additionally in the standard system directories on Windows.<br />

You can test which version of the PHP <strong>TET</strong> binding you have installed with the following<br />

one-line PHP script:<br />

<br />

This will display a long info page about your current PHP configuration. On this page<br />

check the section titled tet. If this section contains the phrase<br />

<strong>PDFlib</strong> <strong>TET</strong> Support<br />

enabled<br />

(plus the <strong>TET</strong> version number) you have successfully installed <strong>TET</strong> for PHP.<br />

> Alternatively, you can load <strong>TET</strong> at runtime with one of the following lines at the start<br />

of your script:<br />

dl("libtet_php.dll");<br />

dl("libtet_php.so");<br />

dl("libtet_php.sl");<br />

dl("libtet_php.dylib");<br />

# for Windows<br />

# for Unix<br />

# for HP-UX<br />

# for Mac OS X<br />

File name handling in PHP. Unqualified file names (without any path component) and<br />

relative file names are handled differently in Unix and Windows versions of PHP:<br />

> PHP on Unix systems will find files without any path component in the directory<br />

where the script is located.<br />

> PHP on Windows will find files without any path component only in the directory<br />

where the PHP DLL is located.<br />

Exception handling. Since PHP 5 supports structured exception handling, <strong>TET</strong> exceptions<br />

will be propagated as PHP exceptions. You can use the standard try/catch technique<br />

to deal with <strong>TET</strong> exceptions:<br />

try {<br />

3.8 PHP Binding 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!