Rendering PDF files in PyQt4 with pypoppler-qt4

Check out the new site at

Poppler is a library for rendering PDF files used by GTK+ and Qt applications. There is a widget for PyQt4 and PyGTK. To compile those widgets you need poppler-bindings package with Qt4 and/or GTK support. Snapshot of pypoppler-qt4 is available on pyqt4-extrawidgets. To compile the widget execute python, make, make install.

In the package you will find, which will open a PDF file given as the argument for the file. You can use up/down arrows to change pages.


In this case Poppler will generate images and QPainter will be used to paint them. As we have images then we can use PictureFlow also:
import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import QtPoppler
from pictureflow import *

app = QApplication(sys.argv)

w = PictureFlow()
d = QtPoppler.Poppler.Document.load('file.pdf')
d.setRenderHint(QtPoppler.Poppler.Document.Antialiasing and QtPoppler.Poppler.Document.TextAntialiasing)

page = 0
pages = d.numPages() - 1
while page < pages:
	page += 1
	print page


PyQt and GUI, 2 January 2009

Check out the new site at
Comment article
Comment article RkBlog main page Search RSS Contact