Python binding to poppler-qt4
Switch branches/tags
Clone or download
wbsoft Merge pull request #15 from jonathanverner/master
Support creating annotations.
Latest commit 576edd3 Apr 1, 2016
Permalink
Failed to load latest commit information.
demo Add a demo script showing how to merge annotations. Mar 31, 2016
.gitignore Add two module functions to get version information (fixes #8) Feb 15, 2015
ChangeLog add __len__, __getitem__ and __bool__ to Document Feb 24, 2015
INSTALL name distutils --install-layout=deb in INSTALL Nov 22, 2011
LICENSE add type conversions, license change to LGPL due to code from PyKDE4 Oct 14, 2010
MANIFEST.in add setup.cfg but not the autogerenated version.sip Feb 17, 2015
README.rst add __len__, __getitem__ and __bool__ to Document Feb 24, 2015
TODO works with python 2 and 3! Feb 17, 2014
demo.py simple demo, inspired by a demo by Csaba Szepesvari Apr 11, 2012
poppler-annotation.sip added the Style class Aug 19, 2015
poppler-convert.sip suppport poppler versions from 0.12.0 on by disabling sip definitions… Oct 24, 2010
poppler-document.sip add __len__, __getitem__ and __bool__ to Document Feb 24, 2015
poppler-embedded-file.sip restructuring Feb 17, 2015
poppler-font-info.sip restructuring Feb 17, 2015
poppler-font-iterator.sip restructuring Feb 17, 2015
poppler-form.sip fix issue #12 (hopefully) Feb 13, 2014
poppler-link-destination.sip restructuring Feb 17, 2015
poppler-link.sip restructuring Feb 17, 2015
poppler-movie-object.sip restructuring Feb 17, 2015
poppler-opt-content-model.sip restructuring Feb 17, 2015
poppler-page-transition.sip initial code Oct 13, 2010
poppler-page.sip Add the addAnnotation method of the Page class. Mar 31, 2016
poppler-qt4.sip restructuring Feb 17, 2015
poppler-sound-object.sip restructuring Feb 17, 2015
poppler-text-box.sip restructuring Feb 17, 2015
setup.cfg setup.cfg Feb 17, 2015
setup.py use full README.rst as long description Feb 17, 2015
types.sip fixes for compiling with python 3.2.2, thanks to Csaba Szepesvari Apr 11, 2012

README.rst

python-poppler-qt4

A Python binding for libpoppler-qt4 that aims for completeness and for being actively maintained.

Created and currently maintained by Wilbert Berendsen <wbsoft@xs4all.nl>.

Homepage: https://pypi.python.org/pypi/python-poppler-qt4/

Usage:

import popplerqt4
d = popplerqt4.Poppler.Document.load('file.pdf')

Documentation

The Python API closely follows the Poppler Qt4 C++ interface library API, documented at http://people.freedesktop.org/~aacid/docs/qt4/ .

Whereever the C++ API requires QList, QSet or QLinkedList, any Python sequence can be used. API calls that return QList, QSet or QLinkedList all return Python lists.

There are a few differences:

Poppler::Document::getPdfVersion(int *major, int *minor) can simply be called as d.getPdfVersion(), (where d is a Poppler::Document instance); it will return a tuple of two integers (major, minor).

Poppler::Document has __len__ and __getitem__ methods, corresponding to numPages() and page(int num).

Poppler::FontIterator (returned by Poppler::Document::newFontIterator) is also a Python iterable (e.g. has __iter__() and __next__() methods). So although you can use:

it = document.newFontIterator()
while it.hasNext():
    fonts = it.next()  # list of FontInfo objects
    ...

you can also use the more Pythonic:

for fonts in document.newFontIterator():
    ...

In addition to the Poppler namespace, there are two toplevel module functions:

popplerqt4.version()
returns the version of the python-poppler-qt4 package as a tuple of ints, e.g. (0, 18, 2).
popplerqt4.poppler_version()

returns the version of the linked Poppler-Qt4 library as a tuple of ints, e.g. (0, 24, 5).

This is determined at build time. If at build time the Poppler-Qt4 version could not be determined and was not specified, an empty tuple might be returned.