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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.9 Python Binding<br />

Installing the <strong>TET</strong> Edition for Python. The Python extension mechanism works by<br />

loading shared libraries at runtime. For the <strong>TET</strong> binding to work, the Python interpreter<br />

must have access to the <strong>TET</strong> Python wrapper which will be searched in the directories<br />

listed in the PYTHONPATH environment variable. The name of Python wrapper depends<br />

on the platform:<br />

> Unix: tetlib_py.so<br />

> Mac OS X: tetlib_py.dylib<br />

> Windows: tetlib_py.pyd<br />

Error Handling in Python. The Python binding installs a special error handler which<br />

translates <strong>TET</strong> errors to native Python exceptions. The Python exceptions can be dealt<br />

with by the usual try/catch technique:<br />

try:<br />

...some <strong>TET</strong> instructions...<br />

except <strong>TET</strong>Exception:<br />

print '<strong>TET</strong> Exception caught!'<br />

3.9 Python Binding 31

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

Saved successfully!

Ooh no, something went wrong!