10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

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.

2.9 Python BindingInstalling the PDFlib Python Edition. The Python 1 extension mechanism works byloading shared libraries at runtime. For the PDFlib binding to work, the Python interpretermust have access to the PDFlib Python wrapper:> Unix: the library pdflib_py.so (on Mac OS X: pdflib_py.dylib) will be searched in the directorieslisted in the PYTHONPATH environment variable.> Windows: the library pdflib_py.dll will be searched in the directories listed in thePYTHONPATH environment variable.Error Handling in Python. The Python binding installs a special error handler whichtranslates PDFlib errors to native Python exceptions. The Python exceptions can bedealt with by the usual try/catch technique:try:...some PDFlib instructions...except PDFlibException:print 'PDFlib Exception caught!'Configuring the old-style Python binding without Unicode support. By default, the Pythonbinding is Unicode-aware. For compatibility purposes we also supply a non-Unicode-awareversion of the Python binding. Although this is not recommended for newapplications, you may want to use the old-style Python binding without Unicode supportfor older applications which do not properly deal with Unicode strings. In this situationyou can configure the Python binding as follows:> Rename pdflib_py.so to nupdflib_py.so> Add the the following to your code:from nupdflib_py import *1. See www.python.org2.9 Python Binding 39

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

Saved successfully!

Ooh no, something went wrong!