A Python binding for libpoppler-qt5 that aims for completeness and for being actively maintained.
Created and currently maintained by Wilbert Berendsen <firstname.lastname@example.org>.
import popplerqt5 d = popplerqt5.Poppler.Document.load('file.pdf')
The Python API closely follows the Poppler Qt5 C++ interface library API, documented at https://poppler.freedesktop.org/api/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
store() methods in the
Annotation subclasses. So, using
PyQt5 >= 5.4 is recommended.
Wherever the C++ API requires
Python sequence can be used.
API calls that return
QLinkedList all return Python
There are a few other differences:
Poppler::Document::getPdfVersion(int *major, int *minor) can simply be
d is a
instance); it will return a tuple of two integers (major, minor).
__getitem__ methods, corresponding
Poppler::FontIterator (returned by
is also a Python iterable (e.g. has
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:
- returns the version of the
python-poppler-qt5package as a tuple of ints, e.g.
(0, 18, 2).
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.