Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpdfdocument.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPDFDOCUMENT_H
5#define QPDFDOCUMENT_H
6
7#include <QtPdf/qtpdfglobal.h>
8
9#include <QtCore/qobject.h>
10#include <QtCore/QAbstractListModel>
11#include <QtGui/qimage.h>
12#include <QtPdf/qpdfdocumentrenderoptions.h>
13#include <QtPdf/qpdfselection.h>
14
16
18class QNetworkReply;
19
20class Q_PDF_EXPORT QPdfDocument : public QObject
21{
23
24 Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged FINAL)
25 Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged FINAL)
26 Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL)
27 Q_PROPERTY(QAbstractListModel* pageModel READ pageModel NOTIFY pageModelChanged FINAL)
28
29public:
30 enum class Status {
31 Null,
32 Loading,
33 Ready,
34 Unloading,
35 Error
36 };
37 Q_ENUM(Status)
38
39 enum class Error {
40 None,
41 Unknown,
42 DataNotYetAvailable,
43 FileNotFound,
44 InvalidFileFormat,
45 IncorrectPassword,
46 UnsupportedSecurityScheme
47 };
49
50 enum class MetaDataField {
51 Title,
52 Subject,
53 Author,
54 Keywords,
55 Producer,
56 Creator,
57 CreationDate,
58 ModificationDate
59 };
60 Q_ENUM(MetaDataField)
61
62 enum class PageModelRole {
63 Label = Qt::UserRole,
64 PointSize,
65 NRoles
66 };
67 Q_ENUM(PageModelRole)
68
69 QPdfDocument() : QPdfDocument(nullptr) {}
70 explicit QPdfDocument(QObject *parent);
71 ~QPdfDocument() override;
72
73 Error load(const QString &fileName);
74
75 Status status() const;
76
77 void load(QIODevice *device);
78 void setPassword(const QString &password);
79 QString password() const;
80
81 QVariant metaData(MetaDataField field) const;
82
83 Error error() const;
84
85 void close();
86
87 int pageCount() const;
88
89 Q_INVOKABLE QSizeF pagePointSize(int page) const;
90
91 Q_INVOKABLE QString pageLabel(int page);
92 Q_INVOKABLE int pageIndexForLabel(const QString &label);
93
95
97
99 Q_INVOKABLE QPdfSelection getSelectionAtIndex(int page, int startIndex, int maxLength);
100 Q_INVOKABLE QPdfSelection getAllText(int page);
101
106 void pageCountChanged(int pageCount);
108
109private:
111 friend class QPdfFile;
113 friend class QPdfPageModel;
114 friend class QPdfSearchModel;
116 friend class QQuickPdfSelection;
117
118 QString fileName() const;
119
120 Q_PRIVATE_SLOT(d, void _q_tryLoadingWithSizeFromContentHeader())
121 Q_PRIVATE_SLOT(d, void _q_copyFromSequentialSourceDevice())
123};
124
126
127#endif // QPDFDOCUMENT_H
IOBluetoothDevice * device
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtGui
Definition qimage.h:37
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:103
The QPdfDocument class loads a PDF document and renders pages from it.
MetaDataField
This enum describes the available fields of meta data.
void pageModelChanged()
void passwordChanged()
Status
This enum describes the current status of the document.
void passwordRequired()
QAbstractListModel * pageModel()
PageModelRole
Roles in pageModel().
void pageCountChanged(int pageCount)
Error
This enum describes the error while attempting the last operation on the document.
void statusChanged(QPdfDocument::Status status)
The QPdfSearchModel class searches for a string in a PDF document and holds the results.
The QPdfSelection class defines a range of text that has been selected on one page in a PDF document,...
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
void statusChanged(QQmlComponent::Status status)
[1]
Definition qlogging.cpp:11
p1 load("image.bmp")
Combined button and popup list for selecting options.
@ UserRole
DBusConnection const char DBusError * error
@ None
Definition qhash.cpp:531
GLuint GLuint end
GLuint GLsizei const GLchar * label
[43]
GLuint start
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
GLsizei maxLength
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QByteArray page
[45]
myWidget render(this)
proxy setPassword("password")