QPdfDocument Class
The QPdfDocument class loads a PDF document and renders pages from it. More...
Header: | #include <QPdfDocument> |
Since: | Qt 5.10 |
Inherits: | QObject |
Public Types
enum | DocumentError { NoError, UnknownError, DataNotYetAvailableError, FileNotFoundError, ..., UnsupportedSecuritySchemeError } |
enum | MetaDataField { Title, Author, Subject, Keywords, ..., ModificationDate } |
enum | Status { Null, Loading, Ready, Unloading, Error } |
Properties
- 1 property inherited from QObject
Public Functions
QPdfDocument(QObject *parent = nullptr) | |
virtual | ~QPdfDocument() |
void | close() |
QPdfDocument::DocumentError | error() const |
QPdfSelection | getAllText(int page) |
QPdfSelection | getSelection(int page, QPointF start, QPointF end) |
QPdfSelection | getSelectionAtIndex(int page, int startIndex, int maxLength) |
QPdfDocument::DocumentError | load(const QString &fileName) |
void | load(QIODevice *device) |
QVariant | metaData(QPdfDocument::MetaDataField field) const |
int | pageCount() const |
QSizeF | pageSize(int page) const |
QString | password() const |
QImage | render(int page, QSize imageSize, QPdfDocumentRenderOptions renderOptions = QPdfDocumentRenderOptions()) |
void | setPassword(const QString &password) |
QPdfDocument::Status | status() const |
- 31 public functions inherited from QObject
Signals
void | pageCountChanged(int pageCount) |
void | passwordChanged() |
void | passwordRequired() |
void | statusChanged(QPdfDocument::Status status) |
- 2 signals inherited from QObject
Static Public Members
const QMetaObject | staticMetaObject |
- 9 static public members inherited from QObject
Additional Inherited Members
Detailed Description
The QPdfDocument class loads a PDF document and renders pages from it.
Member Type Documentation
enum QPdfDocument::DocumentError
enum QPdfDocument::MetaDataField
This enum describes the available fields of meta data.
Constant | Value | Description |
---|---|---|
QPdfDocument::Title | 0 | The document's title as QString. |
QPdfDocument::Author | 2 | The name of the person who created the document as QString. |
QPdfDocument::Subject | 1 | The subject of the document as QString. |
QPdfDocument::Keywords | 3 | Keywords associated with the document as QString. |
QPdfDocument::Creator | 5 | If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted as QString. |
QPdfDocument::Producer | 4 | If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF as QString. |
QPdfDocument::CreationDate | 6 | The date and time the document was created as QDateTime. |
QPdfDocument::ModificationDate | 7 | The date and time the document was most recently modified as QDateTime. |
See also QPdfDocument::metaData().
enum QPdfDocument::Status
This enum describes the current status of the document.
Constant | Value | Description |
---|---|---|
QPdfDocument::Null | 0 | The initial status after the document has been created or after it has been closed. |
QPdfDocument::Loading | 1 | The status after load() has been called and before the document is fully loaded. |
QPdfDocument::Ready | 2 | The status when the document is fully loaded and its data can be accessed. |
QPdfDocument::Unloading | 3 | The status after close() has been called on an open document. At this point the document is still valid and all its data can be accessed. |
QPdfDocument::Error | 4 | The status after Loading, if loading has failed. |
See also QPdfDocument::status().
Property Documentation
pageCount : const int
Access functions:
int | pageCount() const |
Notifier signal:
void | pageCountChanged(int pageCount) |
password : QString
Access functions:
QString | password() const |
void | setPassword(const QString &password) |
Notifier signal:
void | passwordChanged() |
status : const Status
Access functions:
QPdfDocument::Status | status() const |
Notifier signal:
void | statusChanged(QPdfDocument::Status status) |
Member Function Documentation
QPdfDocument::QPdfDocument(QObject *parent = nullptr)
Constructs a new document with parent object parent.
[virtual]
QPdfDocument::~QPdfDocument()
Destroys the document.
void QPdfDocument::close()
Closes the document.
QPdfDocument::DocumentError QPdfDocument::error() const
QPdfSelection QPdfDocument::getAllText(int page)
Returns all the text and its bounds on the given page.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
Returns information about the text on the given page that can be found between the given start and end points, if any.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QPdfSelection QPdfDocument::getSelectionAtIndex(int page, int startIndex, int maxLength)
Returns information about the text on the given page that can be found beginning at the given startIndex with at most maxLength characters.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QPdfDocument::DocumentError QPdfDocument::load(const QString &fileName)
void QPdfDocument::load(QIODevice *device)
QVariant QPdfDocument::metaData(QPdfDocument::MetaDataField field) const
Returns the meta data of the document for the given field.
int QPdfDocument::pageCount() const
Returns the amount of pages for the loaded document or 0
if no document is loaded.
Note: Getter function for property pageCount.
QSizeF QPdfDocument::pageSize(int page) const
[signal]
void QPdfDocument::passwordRequired()
QImage QPdfDocument::render(int page, QSize imageSize, QPdfDocumentRenderOptions renderOptions = QPdfDocumentRenderOptions())
Renders the page into a QImage of size imageSize according to the provided renderOptions.
Returns the rendered page or an empty image in case of an error.
Note: If the imageSize does not match the aspect ratio of the page in the PDF document, the page is rendered scaled, so that it covers the complete imageSize.
QPdfDocument::Status QPdfDocument::status() const
Returns the current status of the document.
Note: Getter function for property status.