The pdf module

PDF rendering backend using QtPdf.

Bases: Link

A link that encapsulates QPdfLinkModel data.

property fileName

The file name if this is an external link.

property isExternal

Indicates whether this is an external link.

property targetPage

If this is an internal link, the page number to which the link should jump; otherwise -1.

property url

The URL the link points to.

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

Bases: AbstractRenderedPage

A Page capable of displaying one page of a QPdfDocument instance.

It has two additional instance attributes:

document: the QPdfDocument instance pageNumber: the page number to render

classmethod loadDocument(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 QtPdf 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 PDF document, and yield of instances of this class.

The filename can also be a QByteArray or a QPdfDocument instance. The specified Renderer is used, or else the global PDF renderer.

mutex()[source]

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

group()[source]

Reimplemented to return the document our page is displayed from.

ident()[source]

Reimplemented to return the page number of this page.

text(rect)[source]

Returns text inside rectangle.

Return links inside the document.

renderer = <qpageview.pdf.PdfRenderer object>
class PdfDocument(source=None, renderer=None)[source]

Bases: SingleSourceDocument

A lazily loaded PDF document.

pageClass

alias of PdfPage

invalidate()[source]

Reimplemented to clear the Document reference.

createPages()[source]

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.

document()[source]

Return the QPdfDocument object.

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

class PdfRenderer(cache=None)[source]

Bases: AbstractRenderer

oversampleThreshold = 96
tiles(width, height)[source]

Yield four-tuples Tile(x, y, w, h) describing the tiles to render.

For the QtPdf backend, this always returns a single tile covering the entire page because QtPdf does not support selectively rendering a smaller area.

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

Draw a tile on the painter.

The painter is already at the right position and rotation.

load(source)[source]

Load a PDF document.

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

  • a filename

  • a QByteArray instance.

Returns None if the document could not be loaded.