The poppler module

Interface with popplerqt5, popplerqt5-specific classes etc.

This module depends on popplerqt5, although it can be imported when popplerqt5 is not available.

You need this module to display PDF documents.


A Link that encapsulates a Poppler.Link object.

property url

The url the link points to.

class PopplerPage(document, pageNumber, renderer=None)[source]


A Page capable of displaying one page of a Poppler.Document instance.

It has two additional instance attributes:

document: the Poppler.Document instance pageNumber: the page number to render

classmethod loadPopplerDocument(document, renderer=None, pageSlice=None)[source]

Convenience class method yielding instances of this class.

The Page instances are created from the document, in page number order. The specified Renderer is used, or else the global poppler renderer. If pageSlice is given, it should be a slice object and only those pages are then loaded.

classmethod load(filename, renderer=None)[source]

Load a Poppler document, and yield of instances of this class.

The filename can also be a QByteArray or a popplerqt5.Poppler.Document instance. The specified Renderer is used, or else the global poppler renderer.


No two pages of same Poppler document are rendered at the same time.


Reimplemented to return the Poppler document our page displays a page from.


Reimplemented to return the page number of this page.


Returns text inside rectangle.

Reimplemented to use a different caching mechanism.

renderer = <qpageview.poppler.PopplerRenderer object>
class PopplerDocument(source=None, renderer=None)[source]

Bases: qpageview.document.SingleSourceDocument

A lazily loaded Poppler (PDF) document.


alias of qpageview.poppler.PopplerPage


Reimplemented to clear the Poppler Document reference.


Implement this method to create and yield the pages.

This method is only called once. After altering filename,-s or source,-s, or invalidate(), it is called again.


Return the Poppler Document object.

Returns None if no source was yet set, and False if loading failed.

class PopplerRenderer(cache=None)[source]

Bases: qpageview.render.AbstractRenderer

renderBackend = 0
printRenderBackend = 0
oversampleThreshold = 96
render(page, key, tile, paperColor=None)[source]

Generate an image for the Page referred to by key.


Set the poppler render hints we want to set.

setup(doc, backend=None, paperColor=None)[source]

Use the poppler document in context, properly configured and locked.

render_poppler_image(doc, pageNum, xres=72.0, yres=72.0, x=- 1, y=- 1, w=- 1, h=- 1, rotate=0, paperColor=None)[source]

Render an image, almost like calling page.renderToImage().

The document is properly locked during rendering and render options are set.

draw(page, painter, key, tile, paperColor=None)[source]

Draw a tile on the painter.

The painter is already at the right position and rotation. For the Poppler page and renderer, draw() is only used for printing. (See AbstractPage.print().)


Load a Poppler document.

Source may be:
  • a Poppler document, which is then simply returned :-)

  • a filename

  • q QByteArray instance.

Returns None if popplerqt5 is not available or the document could not be loaded.