QPdfPageRenderer Class

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

Header: #include <QPdfPageRenderer>
Since: Qt 5.11
Inherits: QObject

This class was introduced in Qt 5.11.

Public Types

enum class RenderMode { MultiThreaded, SingleThreaded }

Properties

Public Functions

QPdfPageRenderer(QObject *parent = nullptr)
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.

ConstantValueDescription
QPdfPageRenderer::RenderMode::MultiThreaded0All pages are rendered in a separate worker thread.
QPdfPageRenderer::RenderMode::SingleThreaded1All 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

QPdfPageRenderer::QPdfPageRenderer(QObject *parent = nullptr)

Constructs a page renderer object with parent object parent.

[override virtual] 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.

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.