- Qt 6.10
- Qt PDF
- C++ Classes
- QPdfPageRenderer
- Qt 6.10.0 Reference Documentation

# QPdfPageRenderer Class

The QPdfPageRenderer class encapsulates the rendering of pages of a PDF document. More...

Header: | `#include <QPdfPageRenderer>`
Inherits: | QObject

- List of all members, including inherited members

## Public Types

enum class | RenderMode { MultiThreaded, SingleThreaded }

## Properties

- document : QPdfDocument*
- renderMode : RenderMode

## Public Functions

| QPdfPageRenderer(QObject *parent)
virtual | ~QPdfPageRenderer() override
QPdfDocument * | document() const
QPdfPageRenderer::RenderMode | renderMode() const
quint64 | requestPage(int pageNumber, QSize imageSize, QPdfDocumentRenderOptions options = QPdfDocumentRenderOptions())
void | setDocument(QPdfDocument *document)
void | setRenderMode(QPdfPageRenderer::RenderMode mode)

## Signals

void | documentChanged(QPdfDocument *document)
void | renderModeChanged(QPdfPageRenderer::RenderMode renderMode)

## Detailed Description

The QPdfPageRenderer contains a queue that collects all render requests that are invoked through requestPage(). Depending on the configured RenderMode the QPdfPageRenderer processes this queue in the main UI thread on next event loop invocation (`RenderMode::SingleThreaded`) or in a separate worker thread (`RenderMode::MultiThreaded`) and emits the result through the pageRendered() signal for each request once the rendering is done.

See also QPdfDocument.

## Member Type Documentation

### enum class QPdfPageRenderer::RenderMode

This enum describes how the pages are rendered.

Constant | Value | Description
--- | --- | ---
`QPdfPageRenderer::RenderMode::MultiThreaded` | `0` | All pages are rendered in a separate worker thread.
`QPdfPageRenderer::RenderMode::SingleThreaded` | `1` | All pages are rendered in the main UI thread (default).

See also renderMode() and setRenderMode().

## Property Documentation

### document : QPdfDocument*

This property holds the document instance this object renders the pages from.

By default, this property is `nullptr`.

Access functions:

QPdfDocument * | document() const
void | setDocument(QPdfDocument *document)

Notifier signal:

void | documentChanged(QPdfDocument *document)

See also document(), setDocument(), and QPdfDocument.

### renderMode : RenderMode

This property holds the mode the renderer uses to render the pages.

By default, this property is `RenderMode::SingleThreaded`.

Access functions:

QPdfPageRenderer::RenderMode | renderMode() const
void | setRenderMode(QPdfPageRenderer::RenderMode mode)

Notifier signal:

void | renderModeChanged(QPdfPageRenderer::RenderMode renderMode)

See also setRenderMode() and RenderMode.

## Member Function Documentation

### `[explicit]` QPdfPageRenderer::QPdfPageRenderer(QObject *parent)

Constructs a page renderer object with parent object parent.

### `[override virtual noexcept]` QPdfPageRenderer::~QPdfPageRenderer()

Destroys the page renderer object.

### QPdfDocument *QPdfPageRenderer::document() const

Returns the document this objects renders the pages from, or a `nullptr` if none has been set before.

Note: Getter function for property document.

See also setDocument() and QPdfDocument.

### QPdfPageRenderer::RenderMode QPdfPageRenderer::renderMode() const

Returns the mode of how the pages are rendered.

Note: Getter function for property renderMode.

See also setRenderMode() and RenderMode.

### quint64 QPdfPageRenderer::requestPage(int pageNumber, QSize imageSize, QPdfDocumentRenderOptions options = QPdfDocumentRenderOptions())

Requests the renderer to render the page pageNumber into a QImage of size imageSize according to the provided options.

Once the rendering is done the pageRendered() signal is emitted with the result as parameters.

The return value is an ID that uniquely identifies the render request. If a request with the same parameters is still in the queue, the ID of that queued request is returned.

### void QPdfPageRenderer::setDocument(QPdfDocument *document)

Sets the document this object renders the pages from.

Note: Setter function for property document.

See also document() and QPdfDocument.

### void QPdfPageRenderer::setRenderMode(QPdfPageRenderer::RenderMode mode)

Sets the mode of how the pages are rendered to mode.

Note: Setter function for property renderMode.

See also renderMode() and RenderMode.