Python binding to libpoppler-qt5
Switch branches/tags
Clone or download
wbsoft Merge pull request #10 from anthonyfok/patch-1
Fix typo: higlight -> highlight
Latest commit 50fb2eb Feb 14, 2017
Permalink
Failed to load latest commit information.
demo also add page.addAnnotation here Apr 1, 2016
.gitignore initial import, disable the QtXml-related methods Feb 21, 2015
ChangeLog initial import, disable the QtXml-related methods Feb 21, 2015
INSTALL initial import, disable the QtXml-related methods Feb 21, 2015
LICENSE initial import, disable the QtXml-related methods Feb 21, 2015
MANIFEST.in initial import, disable the QtXml-related methods Feb 21, 2015
README.rst upd readme and add __bool__ Feb 24, 2015
TODO Update TODO Feb 21, 2015
demo.py change some QtGui to QtWidgets Dec 23, 2016
poppler-annotation.sip Fix typo: higlight -> highlight Dec 15, 2016
poppler-convert.sip work in progress complete api, add docstrings Feb 23, 2015
poppler-document.sip upd readme and add __bool__ Feb 24, 2015
poppler-embedded-file.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-font-info.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-font-iterator.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-form.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-link-destination.sip doc Feb 23, 2015
poppler-link.sip first successful compile Feb 24, 2015
poppler-movie-object.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-opt-content-model.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-page-transition.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-page.sip also add page.addAnnotation here Apr 1, 2016
poppler-qt5.sip %Import QtXml/QtXmlmod.sip if available Sep 5, 2015
poppler-sound-object.sip initial import, disable the QtXml-related methods Feb 21, 2015
poppler-text-box.sip initial import, disable the QtXml-related methods Feb 21, 2015
setup.cfg initial import, disable the QtXml-related methods Feb 21, 2015
setup.py oops Mar 27, 2016
types.sip initial import, disable the QtXml-related methods Feb 21, 2015

README.rst

python-poppler-qt5

A Python binding for libpoppler-qt5 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-qt5/

Usage:

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

Documentation

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

Note: Releases of PyQt5 < 5.4 currently do not support the QtXml module, all methods that use the QDomDocument, QDomElement and QDomNode types are disabled. This concerns the Document::toc() method and some constructors and the store() methods in the Annotation subclasses. So, using PyQt5 >= 5.4 is recommended.

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 other 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:

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

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

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